// AUTOGENERATED FILE. DO NOT MODIFY.

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

#include "unpack3.h"



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

	int32_t value;

	// read output[0]: from bit 0 to 2
	value = ((uint32_t)(input[0] & 0xe0) << 24);
	output[0] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 0 to 2
	value = ((uint32_t)(input[0] & 0xe0) << 24);
	output[0] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 1 to 3
	value = ((uint32_t)(input[0] & 0x70) << 25);
	output[0] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 1 to 3
	value = ((uint32_t)(input[0] & 0x70) << 25);
	output[0] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 2 to 4
	value = ((uint32_t)(input[0] & 0x38) << 26);
	output[0] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 2 to 4
	value = ((uint32_t)(input[0] & 0x38) << 26);
	output[0] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[0] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[0] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[0] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[0] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 5 to 7
	value = ((uint32_t)(input[0] & 0x07) << 29);
	output[0] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 5 to 7
	value = ((uint32_t)(input[0] & 0x07) << 29);
	output[0] = (double)(value >> 29);
}

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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

	// read output[0]: from bit 0 to 2
	value = ((uint32_t)(input[0] & 0xe0) << 24);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[1] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 0 to 2
	value = ((uint32_t)(input[0] & 0xe0) << 24);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[1] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 1 to 3
	value = ((uint32_t)(input[0] & 0x70) << 25);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[1] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 1 to 3
	value = ((uint32_t)(input[0] & 0x70) << 25);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[1] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 2 to 4
	value = ((uint32_t)(input[0] & 0x38) << 26);
	output[0] = (double)(value >> 29);

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

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

	uint32_t value;

	// read output[0]: from bit 2 to 4
	value = ((uint32_t)(input[0] & 0x38) << 26);
	output[0] = (double)(value >> 29);

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

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

	int32_t value;

	// read output[0]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[0] = (double)(value >> 29);

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

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

	uint32_t value;

	// read output[0]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[0] = (double)(value >> 29);

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

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

	int32_t value;

	// read output[0]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[0] = (double)(value >> 29);

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

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

	uint32_t value;

	// read output[0]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[0] = (double)(value >> 29);

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

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

	int32_t value;

	// read output[0]: from bit 5 to 7
	value = ((uint32_t)(input[0] & 0x07) << 29);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 8 to 10
	value = ((uint32_t)(input[1] & 0xe0) << 24);
	output[1] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 5 to 7
	value = ((uint32_t)(input[0] & 0x07) << 29);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 8 to 10
	value = ((uint32_t)(input[1] & 0xe0) << 24);
	output[1] = (double)(value >> 29);
}

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

	int32_t value;

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

	// read output[1]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[1] = (double)(value >> 29);
}

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

	uint32_t value;

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

	// read output[1]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[1] = (double)(value >> 29);
}

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

	int32_t value;

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

	// read output[1]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[1] = (double)(value >> 29);
}

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

	uint32_t value;

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

	// read output[1]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[1] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 0 to 2
	value = ((uint32_t)(input[0] & 0xe0) << 24);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[1] = (double)(value >> 29);

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

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

	uint32_t value;

	// read output[0]: from bit 0 to 2
	value = ((uint32_t)(input[0] & 0xe0) << 24);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[1] = (double)(value >> 29);

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

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

	int32_t value;

	// read output[0]: from bit 1 to 3
	value = ((uint32_t)(input[0] & 0x70) << 25);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[1] = (double)(value >> 29);

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

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

	uint32_t value;

	// read output[0]: from bit 1 to 3
	value = ((uint32_t)(input[0] & 0x70) << 25);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[1] = (double)(value >> 29);

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

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

	int32_t value;

	// read output[0]: from bit 2 to 4
	value = ((uint32_t)(input[0] & 0x38) << 26);
	output[0] = (double)(value >> 29);

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

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

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

	uint32_t value;

	// read output[0]: from bit 2 to 4
	value = ((uint32_t)(input[0] & 0x38) << 26);
	output[0] = (double)(value >> 29);

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

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

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

	int32_t value;

	// read output[0]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[2] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[2] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[2] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[2] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 5 to 7
	value = ((uint32_t)(input[0] & 0x07) << 29);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 8 to 10
	value = ((uint32_t)(input[1] & 0xe0) << 24);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 11 to 13
	value = ((uint32_t)(input[1] & 0x1c) << 27);
	output[2] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 5 to 7
	value = ((uint32_t)(input[0] & 0x07) << 29);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 8 to 10
	value = ((uint32_t)(input[1] & 0xe0) << 24);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 11 to 13
	value = ((uint32_t)(input[1] & 0x1c) << 27);
	output[2] = (double)(value >> 29);
}

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

	int32_t value;

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

	// read output[1]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[2] = (double)(value >> 29);
}

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

	uint32_t value;

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

	// read output[1]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[2] = (double)(value >> 29);
}

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

	int32_t value;

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

	// read output[1]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[1] = (double)(value >> 29);

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

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

	uint32_t value;

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

	// read output[1]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[1] = (double)(value >> 29);

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

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

	int32_t value;

	// read output[0]: from bit 0 to 2
	value = ((uint32_t)(input[0] & 0xe0) << 24);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[1] = (double)(value >> 29);

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

	// read output[3]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[3] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 0 to 2
	value = ((uint32_t)(input[0] & 0xe0) << 24);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[1] = (double)(value >> 29);

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

	// read output[3]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[3] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 1 to 3
	value = ((uint32_t)(input[0] & 0x70) << 25);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[1] = (double)(value >> 29);

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

	// read output[3]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[3] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 1 to 3
	value = ((uint32_t)(input[0] & 0x70) << 25);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[1] = (double)(value >> 29);

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

	// read output[3]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[3] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 2 to 4
	value = ((uint32_t)(input[0] & 0x38) << 26);
	output[0] = (double)(value >> 29);

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

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

	// read output[3]: from bit 11 to 13
	value = ((uint32_t)(input[1] & 0x1c) << 27);
	output[3] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 2 to 4
	value = ((uint32_t)(input[0] & 0x38) << 26);
	output[0] = (double)(value >> 29);

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

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

	// read output[3]: from bit 11 to 13
	value = ((uint32_t)(input[1] & 0x1c) << 27);
	output[3] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[2] = (double)(value >> 29);

	// read output[3]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[3] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[2] = (double)(value >> 29);

	// read output[3]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[3] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[2] = (double)(value >> 29);

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

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

	uint32_t value;

	// read output[0]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[2] = (double)(value >> 29);

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

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

	int32_t value;

	// read output[0]: from bit 5 to 7
	value = ((uint32_t)(input[0] & 0x07) << 29);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 8 to 10
	value = ((uint32_t)(input[1] & 0xe0) << 24);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 11 to 13
	value = ((uint32_t)(input[1] & 0x1c) << 27);
	output[2] = (double)(value >> 29);

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

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

	uint32_t value;

	// read output[0]: from bit 5 to 7
	value = ((uint32_t)(input[0] & 0x07) << 29);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 8 to 10
	value = ((uint32_t)(input[1] & 0xe0) << 24);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 11 to 13
	value = ((uint32_t)(input[1] & 0x1c) << 27);
	output[2] = (double)(value >> 29);

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

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

	int32_t value;

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

	// read output[1]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[2] = (double)(value >> 29);

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

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

	uint32_t value;

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

	// read output[1]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[2] = (double)(value >> 29);

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

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

	int32_t value;

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

	// read output[1]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[1] = (double)(value >> 29);

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

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

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

	uint32_t value;

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

	// read output[1]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[1] = (double)(value >> 29);

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

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

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

	int32_t value;

	// read output[0]: from bit 0 to 2
	value = ((uint32_t)(input[0] & 0xe0) << 24);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[1] = (double)(value >> 29);

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

	// read output[3]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[3] = (double)(value >> 29);

	// read output[4]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[4] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 0 to 2
	value = ((uint32_t)(input[0] & 0xe0) << 24);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[1] = (double)(value >> 29);

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

	// read output[3]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[3] = (double)(value >> 29);

	// read output[4]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[4] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 1 to 3
	value = ((uint32_t)(input[0] & 0x70) << 25);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[1] = (double)(value >> 29);

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

	// read output[3]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[3] = (double)(value >> 29);

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

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

	uint32_t value;

	// read output[0]: from bit 1 to 3
	value = ((uint32_t)(input[0] & 0x70) << 25);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[1] = (double)(value >> 29);

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

	// read output[3]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[3] = (double)(value >> 29);

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

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

	int32_t value;

	// read output[0]: from bit 2 to 4
	value = ((uint32_t)(input[0] & 0x38) << 26);
	output[0] = (double)(value >> 29);

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

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

	// read output[3]: from bit 11 to 13
	value = ((uint32_t)(input[1] & 0x1c) << 27);
	output[3] = (double)(value >> 29);

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

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

	uint32_t value;

	// read output[0]: from bit 2 to 4
	value = ((uint32_t)(input[0] & 0x38) << 26);
	output[0] = (double)(value >> 29);

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

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

	// read output[3]: from bit 11 to 13
	value = ((uint32_t)(input[1] & 0x1c) << 27);
	output[3] = (double)(value >> 29);

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

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

	int32_t value;

	// read output[0]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[2] = (double)(value >> 29);

	// read output[3]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[3] = (double)(value >> 29);

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

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

	uint32_t value;

	// read output[0]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[2] = (double)(value >> 29);

	// read output[3]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[3] = (double)(value >> 29);

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

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

	int32_t value;

	// read output[0]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[2] = (double)(value >> 29);

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

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

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

	uint32_t value;

	// read output[0]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[2] = (double)(value >> 29);

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

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

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

	int32_t value;

	// read output[0]: from bit 5 to 7
	value = ((uint32_t)(input[0] & 0x07) << 29);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 8 to 10
	value = ((uint32_t)(input[1] & 0xe0) << 24);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 11 to 13
	value = ((uint32_t)(input[1] & 0x1c) << 27);
	output[2] = (double)(value >> 29);

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

	// read output[4]: from bit 17 to 19
	value = ((uint32_t)(input[2] & 0x70) << 25);
	output[4] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 5 to 7
	value = ((uint32_t)(input[0] & 0x07) << 29);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 8 to 10
	value = ((uint32_t)(input[1] & 0xe0) << 24);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 11 to 13
	value = ((uint32_t)(input[1] & 0x1c) << 27);
	output[2] = (double)(value >> 29);

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

	// read output[4]: from bit 17 to 19
	value = ((uint32_t)(input[2] & 0x70) << 25);
	output[4] = (double)(value >> 29);
}

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

	int32_t value;

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

	// read output[1]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[2] = (double)(value >> 29);

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

	// read output[4]: from bit 18 to 20
	value = ((uint32_t)(input[2] & 0x38) << 26);
	output[4] = (double)(value >> 29);
}

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

	uint32_t value;

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

	// read output[1]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[2] = (double)(value >> 29);

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

	// read output[4]: from bit 18 to 20
	value = ((uint32_t)(input[2] & 0x38) << 26);
	output[4] = (double)(value >> 29);
}

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

	int32_t value;

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

	// read output[1]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[1] = (double)(value >> 29);

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

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

	// read output[4]: from bit 19 to 21
	value = ((uint32_t)(input[2] & 0x1c) << 27);
	output[4] = (double)(value >> 29);
}

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

	uint32_t value;

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

	// read output[1]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[1] = (double)(value >> 29);

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

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

	// read output[4]: from bit 19 to 21
	value = ((uint32_t)(input[2] & 0x1c) << 27);
	output[4] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 0 to 2
	value = ((uint32_t)(input[0] & 0xe0) << 24);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[1] = (double)(value >> 29);

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

	// read output[3]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[3] = (double)(value >> 29);

	// read output[4]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[4] = (double)(value >> 29);

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

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

	uint32_t value;

	// read output[0]: from bit 0 to 2
	value = ((uint32_t)(input[0] & 0xe0) << 24);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[1] = (double)(value >> 29);

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

	// read output[3]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[3] = (double)(value >> 29);

	// read output[4]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[4] = (double)(value >> 29);

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

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

	int32_t value;

	// read output[0]: from bit 1 to 3
	value = ((uint32_t)(input[0] & 0x70) << 25);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[1] = (double)(value >> 29);

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

	// read output[3]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[3] = (double)(value >> 29);

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

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

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

	uint32_t value;

	// read output[0]: from bit 1 to 3
	value = ((uint32_t)(input[0] & 0x70) << 25);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[1] = (double)(value >> 29);

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

	// read output[3]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[3] = (double)(value >> 29);

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

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

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

	int32_t value;

	// read output[0]: from bit 2 to 4
	value = ((uint32_t)(input[0] & 0x38) << 26);
	output[0] = (double)(value >> 29);

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

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

	// read output[3]: from bit 11 to 13
	value = ((uint32_t)(input[1] & 0x1c) << 27);
	output[3] = (double)(value >> 29);

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

	// read output[5]: from bit 17 to 19
	value = ((uint32_t)(input[2] & 0x70) << 25);
	output[5] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 2 to 4
	value = ((uint32_t)(input[0] & 0x38) << 26);
	output[0] = (double)(value >> 29);

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

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

	// read output[3]: from bit 11 to 13
	value = ((uint32_t)(input[1] & 0x1c) << 27);
	output[3] = (double)(value >> 29);

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

	// read output[5]: from bit 17 to 19
	value = ((uint32_t)(input[2] & 0x70) << 25);
	output[5] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[2] = (double)(value >> 29);

	// read output[3]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[3] = (double)(value >> 29);

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

	// read output[5]: from bit 18 to 20
	value = ((uint32_t)(input[2] & 0x38) << 26);
	output[5] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[2] = (double)(value >> 29);

	// read output[3]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[3] = (double)(value >> 29);

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

	// read output[5]: from bit 18 to 20
	value = ((uint32_t)(input[2] & 0x38) << 26);
	output[5] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[2] = (double)(value >> 29);

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

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

	// read output[5]: from bit 19 to 21
	value = ((uint32_t)(input[2] & 0x1c) << 27);
	output[5] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[2] = (double)(value >> 29);

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

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

	// read output[5]: from bit 19 to 21
	value = ((uint32_t)(input[2] & 0x1c) << 27);
	output[5] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 5 to 7
	value = ((uint32_t)(input[0] & 0x07) << 29);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 8 to 10
	value = ((uint32_t)(input[1] & 0xe0) << 24);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 11 to 13
	value = ((uint32_t)(input[1] & 0x1c) << 27);
	output[2] = (double)(value >> 29);

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

	// read output[4]: from bit 17 to 19
	value = ((uint32_t)(input[2] & 0x70) << 25);
	output[4] = (double)(value >> 29);

	// read output[5]: from bit 20 to 22
	value = ((uint32_t)(input[2] & 0x0e) << 28);
	output[5] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 5 to 7
	value = ((uint32_t)(input[0] & 0x07) << 29);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 8 to 10
	value = ((uint32_t)(input[1] & 0xe0) << 24);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 11 to 13
	value = ((uint32_t)(input[1] & 0x1c) << 27);
	output[2] = (double)(value >> 29);

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

	// read output[4]: from bit 17 to 19
	value = ((uint32_t)(input[2] & 0x70) << 25);
	output[4] = (double)(value >> 29);

	// read output[5]: from bit 20 to 22
	value = ((uint32_t)(input[2] & 0x0e) << 28);
	output[5] = (double)(value >> 29);
}

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

	int32_t value;

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

	// read output[1]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[2] = (double)(value >> 29);

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

	// read output[4]: from bit 18 to 20
	value = ((uint32_t)(input[2] & 0x38) << 26);
	output[4] = (double)(value >> 29);

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

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

	uint32_t value;

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

	// read output[1]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[2] = (double)(value >> 29);

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

	// read output[4]: from bit 18 to 20
	value = ((uint32_t)(input[2] & 0x38) << 26);
	output[4] = (double)(value >> 29);

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

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

	int32_t value;

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

	// read output[1]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[1] = (double)(value >> 29);

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

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

	// read output[4]: from bit 19 to 21
	value = ((uint32_t)(input[2] & 0x1c) << 27);
	output[4] = (double)(value >> 29);

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

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

	uint32_t value;

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

	// read output[1]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[1] = (double)(value >> 29);

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

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

	// read output[4]: from bit 19 to 21
	value = ((uint32_t)(input[2] & 0x1c) << 27);
	output[4] = (double)(value >> 29);

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

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

	int32_t value;

	// read output[0]: from bit 0 to 2
	value = ((uint32_t)(input[0] & 0xe0) << 24);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[1] = (double)(value >> 29);

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

	// read output[3]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[3] = (double)(value >> 29);

	// read output[4]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[4] = (double)(value >> 29);

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

	// read output[6]: from bit 18 to 20
	value = ((uint32_t)(input[2] & 0x38) << 26);
	output[6] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 0 to 2
	value = ((uint32_t)(input[0] & 0xe0) << 24);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[1] = (double)(value >> 29);

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

	// read output[3]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[3] = (double)(value >> 29);

	// read output[4]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[4] = (double)(value >> 29);

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

	// read output[6]: from bit 18 to 20
	value = ((uint32_t)(input[2] & 0x38) << 26);
	output[6] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 1 to 3
	value = ((uint32_t)(input[0] & 0x70) << 25);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[1] = (double)(value >> 29);

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

	// read output[3]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[3] = (double)(value >> 29);

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

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

	// read output[6]: from bit 19 to 21
	value = ((uint32_t)(input[2] & 0x1c) << 27);
	output[6] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 1 to 3
	value = ((uint32_t)(input[0] & 0x70) << 25);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[1] = (double)(value >> 29);

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

	// read output[3]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[3] = (double)(value >> 29);

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

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

	// read output[6]: from bit 19 to 21
	value = ((uint32_t)(input[2] & 0x1c) << 27);
	output[6] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 2 to 4
	value = ((uint32_t)(input[0] & 0x38) << 26);
	output[0] = (double)(value >> 29);

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

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

	// read output[3]: from bit 11 to 13
	value = ((uint32_t)(input[1] & 0x1c) << 27);
	output[3] = (double)(value >> 29);

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

	// read output[5]: from bit 17 to 19
	value = ((uint32_t)(input[2] & 0x70) << 25);
	output[5] = (double)(value >> 29);

	// read output[6]: from bit 20 to 22
	value = ((uint32_t)(input[2] & 0x0e) << 28);
	output[6] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 2 to 4
	value = ((uint32_t)(input[0] & 0x38) << 26);
	output[0] = (double)(value >> 29);

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

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

	// read output[3]: from bit 11 to 13
	value = ((uint32_t)(input[1] & 0x1c) << 27);
	output[3] = (double)(value >> 29);

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

	// read output[5]: from bit 17 to 19
	value = ((uint32_t)(input[2] & 0x70) << 25);
	output[5] = (double)(value >> 29);

	// read output[6]: from bit 20 to 22
	value = ((uint32_t)(input[2] & 0x0e) << 28);
	output[6] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[2] = (double)(value >> 29);

	// read output[3]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[3] = (double)(value >> 29);

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

	// read output[5]: from bit 18 to 20
	value = ((uint32_t)(input[2] & 0x38) << 26);
	output[5] = (double)(value >> 29);

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

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

	uint32_t value;

	// read output[0]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[2] = (double)(value >> 29);

	// read output[3]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[3] = (double)(value >> 29);

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

	// read output[5]: from bit 18 to 20
	value = ((uint32_t)(input[2] & 0x38) << 26);
	output[5] = (double)(value >> 29);

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

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

	int32_t value;

	// read output[0]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[2] = (double)(value >> 29);

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

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

	// read output[5]: from bit 19 to 21
	value = ((uint32_t)(input[2] & 0x1c) << 27);
	output[5] = (double)(value >> 29);

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

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

	uint32_t value;

	// read output[0]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[2] = (double)(value >> 29);

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

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

	// read output[5]: from bit 19 to 21
	value = ((uint32_t)(input[2] & 0x1c) << 27);
	output[5] = (double)(value >> 29);

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

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

	int32_t value;

	// read output[0]: from bit 5 to 7
	value = ((uint32_t)(input[0] & 0x07) << 29);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 8 to 10
	value = ((uint32_t)(input[1] & 0xe0) << 24);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 11 to 13
	value = ((uint32_t)(input[1] & 0x1c) << 27);
	output[2] = (double)(value >> 29);

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

	// read output[4]: from bit 17 to 19
	value = ((uint32_t)(input[2] & 0x70) << 25);
	output[4] = (double)(value >> 29);

	// read output[5]: from bit 20 to 22
	value = ((uint32_t)(input[2] & 0x0e) << 28);
	output[5] = (double)(value >> 29);

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

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

	uint32_t value;

	// read output[0]: from bit 5 to 7
	value = ((uint32_t)(input[0] & 0x07) << 29);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 8 to 10
	value = ((uint32_t)(input[1] & 0xe0) << 24);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 11 to 13
	value = ((uint32_t)(input[1] & 0x1c) << 27);
	output[2] = (double)(value >> 29);

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

	// read output[4]: from bit 17 to 19
	value = ((uint32_t)(input[2] & 0x70) << 25);
	output[4] = (double)(value >> 29);

	// read output[5]: from bit 20 to 22
	value = ((uint32_t)(input[2] & 0x0e) << 28);
	output[5] = (double)(value >> 29);

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

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

	int32_t value;

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

	// read output[1]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[2] = (double)(value >> 29);

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

	// read output[4]: from bit 18 to 20
	value = ((uint32_t)(input[2] & 0x38) << 26);
	output[4] = (double)(value >> 29);

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

	// read output[6]: from bit 24 to 26
	value = ((uint32_t)(input[3] & 0xe0) << 24);
	output[6] = (double)(value >> 29);
}

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

	uint32_t value;

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

	// read output[1]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[2] = (double)(value >> 29);

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

	// read output[4]: from bit 18 to 20
	value = ((uint32_t)(input[2] & 0x38) << 26);
	output[4] = (double)(value >> 29);

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

	// read output[6]: from bit 24 to 26
	value = ((uint32_t)(input[3] & 0xe0) << 24);
	output[6] = (double)(value >> 29);
}

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

	int32_t value;

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

	// read output[1]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[1] = (double)(value >> 29);

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

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

	// read output[4]: from bit 19 to 21
	value = ((uint32_t)(input[2] & 0x1c) << 27);
	output[4] = (double)(value >> 29);

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

	// read output[6]: from bit 25 to 27
	value = ((uint32_t)(input[3] & 0x70) << 25);
	output[6] = (double)(value >> 29);
}

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

	uint32_t value;

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

	// read output[1]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[1] = (double)(value >> 29);

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

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

	// read output[4]: from bit 19 to 21
	value = ((uint32_t)(input[2] & 0x1c) << 27);
	output[4] = (double)(value >> 29);

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

	// read output[6]: from bit 25 to 27
	value = ((uint32_t)(input[3] & 0x70) << 25);
	output[6] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 0 to 2
	value = ((uint32_t)(input[0] & 0xe0) << 24);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[1] = (double)(value >> 29);

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

	// read output[3]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[3] = (double)(value >> 29);

	// read output[4]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[4] = (double)(value >> 29);

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

	// read output[6]: from bit 18 to 20
	value = ((uint32_t)(input[2] & 0x38) << 26);
	output[6] = (double)(value >> 29);

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

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

	uint32_t value;

	// read output[0]: from bit 0 to 2
	value = ((uint32_t)(input[0] & 0xe0) << 24);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[1] = (double)(value >> 29);

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

	// read output[3]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[3] = (double)(value >> 29);

	// read output[4]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[4] = (double)(value >> 29);

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

	// read output[6]: from bit 18 to 20
	value = ((uint32_t)(input[2] & 0x38) << 26);
	output[6] = (double)(value >> 29);

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

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

	int32_t value;

	// read output[0]: from bit 1 to 3
	value = ((uint32_t)(input[0] & 0x70) << 25);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[1] = (double)(value >> 29);

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

	// read output[3]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[3] = (double)(value >> 29);

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

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

	// read output[6]: from bit 19 to 21
	value = ((uint32_t)(input[2] & 0x1c) << 27);
	output[6] = (double)(value >> 29);

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

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

	uint32_t value;

	// read output[0]: from bit 1 to 3
	value = ((uint32_t)(input[0] & 0x70) << 25);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[1] = (double)(value >> 29);

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

	// read output[3]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[3] = (double)(value >> 29);

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

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

	// read output[6]: from bit 19 to 21
	value = ((uint32_t)(input[2] & 0x1c) << 27);
	output[6] = (double)(value >> 29);

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

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

	int32_t value;

	// read output[0]: from bit 2 to 4
	value = ((uint32_t)(input[0] & 0x38) << 26);
	output[0] = (double)(value >> 29);

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

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

	// read output[3]: from bit 11 to 13
	value = ((uint32_t)(input[1] & 0x1c) << 27);
	output[3] = (double)(value >> 29);

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

	// read output[5]: from bit 17 to 19
	value = ((uint32_t)(input[2] & 0x70) << 25);
	output[5] = (double)(value >> 29);

	// read output[6]: from bit 20 to 22
	value = ((uint32_t)(input[2] & 0x0e) << 28);
	output[6] = (double)(value >> 29);

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

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

	uint32_t value;

	// read output[0]: from bit 2 to 4
	value = ((uint32_t)(input[0] & 0x38) << 26);
	output[0] = (double)(value >> 29);

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

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

	// read output[3]: from bit 11 to 13
	value = ((uint32_t)(input[1] & 0x1c) << 27);
	output[3] = (double)(value >> 29);

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

	// read output[5]: from bit 17 to 19
	value = ((uint32_t)(input[2] & 0x70) << 25);
	output[5] = (double)(value >> 29);

	// read output[6]: from bit 20 to 22
	value = ((uint32_t)(input[2] & 0x0e) << 28);
	output[6] = (double)(value >> 29);

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

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

	int32_t value;

	// read output[0]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[2] = (double)(value >> 29);

	// read output[3]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[3] = (double)(value >> 29);

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

	// read output[5]: from bit 18 to 20
	value = ((uint32_t)(input[2] & 0x38) << 26);
	output[5] = (double)(value >> 29);

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

	// read output[7]: from bit 24 to 26
	value = ((uint32_t)(input[3] & 0xe0) << 24);
	output[7] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 3 to 5
	value = ((uint32_t)(input[0] & 0x1c) << 27);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[2] = (double)(value >> 29);

	// read output[3]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[3] = (double)(value >> 29);

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

	// read output[5]: from bit 18 to 20
	value = ((uint32_t)(input[2] & 0x38) << 26);
	output[5] = (double)(value >> 29);

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

	// read output[7]: from bit 24 to 26
	value = ((uint32_t)(input[3] & 0xe0) << 24);
	output[7] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[2] = (double)(value >> 29);

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

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

	// read output[5]: from bit 19 to 21
	value = ((uint32_t)(input[2] & 0x1c) << 27);
	output[5] = (double)(value >> 29);

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

	// read output[7]: from bit 25 to 27
	value = ((uint32_t)(input[3] & 0x70) << 25);
	output[7] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 4 to 6
	value = ((uint32_t)(input[0] & 0x0e) << 28);
	output[0] = (double)(value >> 29);

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

	// read output[2]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[2] = (double)(value >> 29);

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

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

	// read output[5]: from bit 19 to 21
	value = ((uint32_t)(input[2] & 0x1c) << 27);
	output[5] = (double)(value >> 29);

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

	// read output[7]: from bit 25 to 27
	value = ((uint32_t)(input[3] & 0x70) << 25);
	output[7] = (double)(value >> 29);
}

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

	int32_t value;

	// read output[0]: from bit 5 to 7
	value = ((uint32_t)(input[0] & 0x07) << 29);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 8 to 10
	value = ((uint32_t)(input[1] & 0xe0) << 24);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 11 to 13
	value = ((uint32_t)(input[1] & 0x1c) << 27);
	output[2] = (double)(value >> 29);

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

	// read output[4]: from bit 17 to 19
	value = ((uint32_t)(input[2] & 0x70) << 25);
	output[4] = (double)(value >> 29);

	// read output[5]: from bit 20 to 22
	value = ((uint32_t)(input[2] & 0x0e) << 28);
	output[5] = (double)(value >> 29);

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

	// read output[7]: from bit 26 to 28
	value = ((uint32_t)(input[3] & 0x38) << 26);
	output[7] = (double)(value >> 29);
}

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

	uint32_t value;

	// read output[0]: from bit 5 to 7
	value = ((uint32_t)(input[0] & 0x07) << 29);
	output[0] = (double)(value >> 29);

	// read output[1]: from bit 8 to 10
	value = ((uint32_t)(input[1] & 0xe0) << 24);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 11 to 13
	value = ((uint32_t)(input[1] & 0x1c) << 27);
	output[2] = (double)(value >> 29);

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

	// read output[4]: from bit 17 to 19
	value = ((uint32_t)(input[2] & 0x70) << 25);
	output[4] = (double)(value >> 29);

	// read output[5]: from bit 20 to 22
	value = ((uint32_t)(input[2] & 0x0e) << 28);
	output[5] = (double)(value >> 29);

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

	// read output[7]: from bit 26 to 28
	value = ((uint32_t)(input[3] & 0x38) << 26);
	output[7] = (double)(value >> 29);
}

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

	int32_t value;

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

	// read output[1]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[2] = (double)(value >> 29);

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

	// read output[4]: from bit 18 to 20
	value = ((uint32_t)(input[2] & 0x38) << 26);
	output[4] = (double)(value >> 29);

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

	// read output[6]: from bit 24 to 26
	value = ((uint32_t)(input[3] & 0xe0) << 24);
	output[6] = (double)(value >> 29);

	// read output[7]: from bit 27 to 29
	value = ((uint32_t)(input[3] & 0x1c) << 27);
	output[7] = (double)(value >> 29);
}

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

	uint32_t value;

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

	// read output[1]: from bit 9 to 11
	value = ((uint32_t)(input[1] & 0x70) << 25);
	output[1] = (double)(value >> 29);

	// read output[2]: from bit 12 to 14
	value = ((uint32_t)(input[1] & 0x0e) << 28);
	output[2] = (double)(value >> 29);

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

	// read output[4]: from bit 18 to 20
	value = ((uint32_t)(input[2] & 0x38) << 26);
	output[4] = (double)(value >> 29);

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

	// read output[6]: from bit 24 to 26
	value = ((uint32_t)(input[3] & 0xe0) << 24);
	output[6] = (double)(value >> 29);

	// read output[7]: from bit 27 to 29
	value = ((uint32_t)(input[3] & 0x1c) << 27);
	output[7] = (double)(value >> 29);
}

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

	int32_t value;

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

	// read output[1]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[1] = (double)(value >> 29);

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

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

	// read output[4]: from bit 19 to 21
	value = ((uint32_t)(input[2] & 0x1c) << 27);
	output[4] = (double)(value >> 29);

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

	// read output[6]: from bit 25 to 27
	value = ((uint32_t)(input[3] & 0x70) << 25);
	output[6] = (double)(value >> 29);

	// read output[7]: from bit 28 to 30
	value = ((uint32_t)(input[3] & 0x0e) << 28);
	output[7] = (double)(value >> 29);
}

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

	uint32_t value;

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

	// read output[1]: from bit 10 to 12
	value = ((uint32_t)(input[1] & 0x38) << 26);
	output[1] = (double)(value >> 29);

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

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

	// read output[4]: from bit 19 to 21
	value = ((uint32_t)(input[2] & 0x1c) << 27);
	output[4] = (double)(value >> 29);

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

	// read output[6]: from bit 25 to 27
	value = ((uint32_t)(input[3] & 0x70) << 25);
	output[6] = (double)(value >> 29);

	// read output[7]: from bit 28 to 30
	value = ((uint32_t)(input[3] & 0x0e) << 28);
	output[7] = (double)(value >> 29);
}


unpack_func_t unpack_3bit[UNPACK_3BIT_MAX_COUNT][8][2] = {
	{
		{
			unpack_1_3bit_unsigned_0off,
			unpack_1_3bit_signed_0off,
		},
		{
			unpack_1_3bit_unsigned_1off,
			unpack_1_3bit_signed_1off,
		},
		{
			unpack_1_3bit_unsigned_2off,
			unpack_1_3bit_signed_2off,
		},
		{
			unpack_1_3bit_unsigned_3off,
			unpack_1_3bit_signed_3off,
		},
		{
			unpack_1_3bit_unsigned_4off,
			unpack_1_3bit_signed_4off,
		},
		{
			unpack_1_3bit_unsigned_5off,
			unpack_1_3bit_signed_5off,
		},
		{
			unpack_1_3bit_unsigned_6off,
			unpack_1_3bit_signed_6off,
		},
		{
			unpack_1_3bit_unsigned_7off,
			unpack_1_3bit_signed_7off,
		},
	},
	{
		{
			unpack_2_3bit_unsigned_0off,
			unpack_2_3bit_signed_0off,
		},
		{
			unpack_2_3bit_unsigned_1off,
			unpack_2_3bit_signed_1off,
		},
		{
			unpack_2_3bit_unsigned_2off,
			unpack_2_3bit_signed_2off,
		},
		{
			unpack_2_3bit_unsigned_3off,
			unpack_2_3bit_signed_3off,
		},
		{
			unpack_2_3bit_unsigned_4off,
			unpack_2_3bit_signed_4off,
		},
		{
			unpack_2_3bit_unsigned_5off,
			unpack_2_3bit_signed_5off,
		},
		{
			unpack_2_3bit_unsigned_6off,
			unpack_2_3bit_signed_6off,
		},
		{
			unpack_2_3bit_unsigned_7off,
			unpack_2_3bit_signed_7off,
		},
	},
	{
		{
			unpack_3_3bit_unsigned_0off,
			unpack_3_3bit_signed_0off,
		},
		{
			unpack_3_3bit_unsigned_1off,
			unpack_3_3bit_signed_1off,
		},
		{
			unpack_3_3bit_unsigned_2off,
			unpack_3_3bit_signed_2off,
		},
		{
			unpack_3_3bit_unsigned_3off,
			unpack_3_3bit_signed_3off,
		},
		{
			unpack_3_3bit_unsigned_4off,
			unpack_3_3bit_signed_4off,
		},
		{
			unpack_3_3bit_unsigned_5off,
			unpack_3_3bit_signed_5off,
		},
		{
			unpack_3_3bit_unsigned_6off,
			unpack_3_3bit_signed_6off,
		},
		{
			unpack_3_3bit_unsigned_7off,
			unpack_3_3bit_signed_7off,
		},
	},
	{
		{
			unpack_4_3bit_unsigned_0off,
			unpack_4_3bit_signed_0off,
		},
		{
			unpack_4_3bit_unsigned_1off,
			unpack_4_3bit_signed_1off,
		},
		{
			unpack_4_3bit_unsigned_2off,
			unpack_4_3bit_signed_2off,
		},
		{
			unpack_4_3bit_unsigned_3off,
			unpack_4_3bit_signed_3off,
		},
		{
			unpack_4_3bit_unsigned_4off,
			unpack_4_3bit_signed_4off,
		},
		{
			unpack_4_3bit_unsigned_5off,
			unpack_4_3bit_signed_5off,
		},
		{
			unpack_4_3bit_unsigned_6off,
			unpack_4_3bit_signed_6off,
		},
		{
			unpack_4_3bit_unsigned_7off,
			unpack_4_3bit_signed_7off,
		},
	},
	{
		{
			unpack_5_3bit_unsigned_0off,
			unpack_5_3bit_signed_0off,
		},
		{
			unpack_5_3bit_unsigned_1off,
			unpack_5_3bit_signed_1off,
		},
		{
			unpack_5_3bit_unsigned_2off,
			unpack_5_3bit_signed_2off,
		},
		{
			unpack_5_3bit_unsigned_3off,
			unpack_5_3bit_signed_3off,
		},
		{
			unpack_5_3bit_unsigned_4off,
			unpack_5_3bit_signed_4off,
		},
		{
			unpack_5_3bit_unsigned_5off,
			unpack_5_3bit_signed_5off,
		},
		{
			unpack_5_3bit_unsigned_6off,
			unpack_5_3bit_signed_6off,
		},
		{
			unpack_5_3bit_unsigned_7off,
			unpack_5_3bit_signed_7off,
		},
	},
	{
		{
			unpack_6_3bit_unsigned_0off,
			unpack_6_3bit_signed_0off,
		},
		{
			unpack_6_3bit_unsigned_1off,
			unpack_6_3bit_signed_1off,
		},
		{
			unpack_6_3bit_unsigned_2off,
			unpack_6_3bit_signed_2off,
		},
		{
			unpack_6_3bit_unsigned_3off,
			unpack_6_3bit_signed_3off,
		},
		{
			unpack_6_3bit_unsigned_4off,
			unpack_6_3bit_signed_4off,
		},
		{
			unpack_6_3bit_unsigned_5off,
			unpack_6_3bit_signed_5off,
		},
		{
			unpack_6_3bit_unsigned_6off,
			unpack_6_3bit_signed_6off,
		},
		{
			unpack_6_3bit_unsigned_7off,
			unpack_6_3bit_signed_7off,
		},
	},
	{
		{
			unpack_7_3bit_unsigned_0off,
			unpack_7_3bit_signed_0off,
		},
		{
			unpack_7_3bit_unsigned_1off,
			unpack_7_3bit_signed_1off,
		},
		{
			unpack_7_3bit_unsigned_2off,
			unpack_7_3bit_signed_2off,
		},
		{
			unpack_7_3bit_unsigned_3off,
			unpack_7_3bit_signed_3off,
		},
		{
			unpack_7_3bit_unsigned_4off,
			unpack_7_3bit_signed_4off,
		},
		{
			unpack_7_3bit_unsigned_5off,
			unpack_7_3bit_signed_5off,
		},
		{
			unpack_7_3bit_unsigned_6off,
			unpack_7_3bit_signed_6off,
		},
		{
			unpack_7_3bit_unsigned_7off,
			unpack_7_3bit_signed_7off,
		},
	},
	{
		{
			unpack_8_3bit_unsigned_0off,
			unpack_8_3bit_signed_0off,
		},
		{
			unpack_8_3bit_unsigned_1off,
			unpack_8_3bit_signed_1off,
		},
		{
			unpack_8_3bit_unsigned_2off,
			unpack_8_3bit_signed_2off,
		},
		{
			unpack_8_3bit_unsigned_3off,
			unpack_8_3bit_signed_3off,
		},
		{
			unpack_8_3bit_unsigned_4off,
			unpack_8_3bit_signed_4off,
		},
		{
			unpack_8_3bit_unsigned_5off,
			unpack_8_3bit_signed_5off,
		},
		{
			unpack_8_3bit_unsigned_6off,
			unpack_8_3bit_signed_6off,
		},
		{
			unpack_8_3bit_unsigned_7off,
			unpack_8_3bit_signed_7off,
		},
	},
};
