/*******************************************************************
              DCT coefficient table 'B-14' module
 *******************************************************************/

#define B14_C
#include "b14.h"

int read_dct_coefficient_b14(VIDEO_STREAM *in, short *level, unsigned char *run);

static int eob(VIDEO_STREAM *in, short *level, unsigned char *run);
static int esc(VIDEO_STREAM *in, short *level, unsigned char *run);
static int l9b(VIDEO_STREAM *in, short *level, unsigned char *run);
static int o9b(VIDEO_STREAM *in, short *level, unsigned char *run);

int read_dct_coefficient_b14(VIDEO_STREAM *in, short *level, unsigned char *run)
{
	int code;

	static const rdc table[] = {
		o9b, esc, l9b, l9b, l9b, l9b, l9b, l9b,
		l9b, l9b, l9b, l9b, l9b, l9b, l9b, l9b,
		l9b, l9b, l9b, l9b, l9b, l9b, l9b, l9b,
		l9b, l9b, l9b, l9b, l9b, l9b, l9b, l9b,
		eob, eob, eob, eob, eob, eob, eob, eob,
		eob, eob, eob, eob, eob, eob, eob, eob,
		l9b, l9b, l9b, l9b, l9b, l9b, l9b, l9b,
		l9b, l9b, l9b, l9b, l9b, l9b, l9b, l9b,
	};

	code = read_bits(in, 6);

	return table[code](in, level, run);
}

static int eob(VIDEO_STREAM *in, short *level, unsigned char *run)
{
	erase_bits(in, 2);

	return 0;
}

static int esc(VIDEO_STREAM *in, short *level, unsigned char *run)
{
	erase_bits(in, 6);
	
	read_fixed_length_dct_coefficient(in, level, run);
	return 1;
}

static int l9b(VIDEO_STREAM *in, short *level, unsigned char *run)
{
	int code;

	static const DCT_COEFFICIENT_VLC_ELEMENT table[] = {
		{2,2,8},{2,2,8},{-2,2,8},{-2,2,8},{1,9,8},{1,9,8},{-1,9,8},{-1,9,8},
		{4,0,8},{4,0,8},{-4,0,8},{-4,0,8},{1,8,8},{1,8,8},{-1,8,8},{-1,8,8},
		{1,7,7},{1,7,7},{1,7,7},{1,7,7},{-1,7,7},{-1,7,7},{-1,7,7},{-1,7,7},
		{1,6,7},{1,6,7},{1,6,7},{1,6,7},{-1,6,7},{-1,6,7},{-1,6,7},{-1,6,7},
		{2,1,7},{2,1,7},{2,1,7},{2,1,7},{-2,1,7},{-2,1,7},{-2,1,7},{-2,1,7},
		{1,5,7},{1,5,7},{1,5,7},{1,5,7},{-1,5,7},{-1,5,7},{-1,5,7},{-1,5,7},
		{1,13,9},{-1,13,9},{6,0,9},{-6,0,9},{1,12,9},{-1,12,9},{1,11,9},{-1,11,9},
		{2,3,9},{-2,3,9},{3,1,9},{-3,1,9},{5,0,9},{-5,0,9},{1,10,9},{-1,10,9},
		{3,0,6},{3,0,6},{3,0,6},{3,0,6},{3,0,6},{3,0,6},{3,0,6},{3,0,6},
		{-3,0,6},{-3,0,6},{-3,0,6},{-3,0,6},{-3,0,6},{-3,0,6},{-3,0,6},{-3,0,6},
		{1,4,6},{1,4,6},{1,4,6},{1,4,6},{1,4,6},{1,4,6},{1,4,6},{1,4,6},
		{-1,4,6},{-1,4,6},{-1,4,6},{-1,4,6},{-1,4,6},{-1,4,6},{-1,4,6},{-1,4,6},
		{1,3,6},{1,3,6},{1,3,6},{1,3,6},{1,3,6},{1,3,6},{1,3,6},{1,3,6},
		{-1,3,6},{-1,3,6},{-1,3,6},{-1,3,6},{-1,3,6},{-1,3,6},{-1,3,6},{-1,3,6},
		{2,0,5},{2,0,5},{2,0,5},{2,0,5},{2,0,5},{2,0,5},{2,0,5},{2,0,5},
		{2,0,5},{2,0,5},{2,0,5},{2,0,5},{2,0,5},{2,0,5},{2,0,5},{2,0,5},
		{-2,0,5},{-2,0,5},{-2,0,5},{-2,0,5},{-2,0,5},{-2,0,5},{-2,0,5},{-2,0,5},
		{-2,0,5},{-2,0,5},{-2,0,5},{-2,0,5},{-2,0,5},{-2,0,5},{-2,0,5},{-2,0,5},
		{1,2,5},{1,2,5},{1,2,5},{1,2,5},{1,2,5},{1,2,5},{1,2,5},{1,2,5},
		{1,2,5},{1,2,5},{1,2,5},{1,2,5},{1,2,5},{1,2,5},{1,2,5},{1,2,5},
		{-1,2,5},{-1,2,5},{-1,2,5},{-1,2,5},{-1,2,5},{-1,2,5},{-1,2,5},{-1,2,5},
		{-1,2,5},{-1,2,5},{-1,2,5},{-1,2,5},{-1,2,5},{-1,2,5},{-1,2,5},{-1,2,5},
		{1,1,4},{1,1,4},{1,1,4},{1,1,4},{1,1,4},{1,1,4},{1,1,4},{1,1,4},
		{1,1,4},{1,1,4},{1,1,4},{1,1,4},{1,1,4},{1,1,4},{1,1,4},{1,1,4},
		{1,1,4},{1,1,4},{1,1,4},{1,1,4},{1,1,4},{1,1,4},{1,1,4},{1,1,4},
		{1,1,4},{1,1,4},{1,1,4},{1,1,4},{1,1,4},{1,1,4},{1,1,4},{1,1,4},
		{-1,1,4},{-1,1,4},{-1,1,4},{-1,1,4},{-1,1,4},{-1,1,4},{-1,1,4},{-1,1,4},
		{-1,1,4},{-1,1,4},{-1,1,4},{-1,1,4},{-1,1,4},{-1,1,4},{-1,1,4},{-1,1,4},
		{-1,1,4},{-1,1,4},{-1,1,4},{-1,1,4},{-1,1,4},{-1,1,4},{-1,1,4},{-1,1,4},
		{-1,1,4},{-1,1,4},{-1,1,4},{-1,1,4},{-1,1,4},{-1,1,4},{-1,1,4},{-1,1,4},
		{0,0,3},{0,0,3},{0,0,3},{0,0,3},{0,0,3},{0,0,3},{0,0,3},{0,0,3},
		{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},
		{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},
		{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},
		{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},
		{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},
		{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},
		{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},
		{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},
		{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},
		{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},
		{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},
		{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},
		{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},
		{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},
		{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},
		{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},
		{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},
		{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},
		{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},
		{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},
		{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},
		{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},
		{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},{1,0,3},
		{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},
		{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},
		{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},
		{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},
		{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},
		{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},
		{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},
		{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},{-1,0,3},
	};

	code = read_bits(in, 9);
	code -= 16;

	*run = table[code].run;
	*level = table[code].level;

	erase_bits(in, table[code].length);

	return 1;
}

static int o9b(VIDEO_STREAM *in, short *level, unsigned char *run)
{
	int code;

	static const DCT_COEFFICIENT_VLC_ELEMENT table[] = {
		{18,1,17},{-18,1,17},{17,1,17},{-17,1,17},{16,1,17},{-16,1,17},{15,1,17},{-15,1,17},
		{3,6,17},{-3,6,17},{2,16,17},{-2,16,17},{2,15,17},{-2,15,17},{2,14,17},{-2,14,17},
		{2,13,17},{-2,13,17},{2,12,17},{-2,12,17},{2,11,17},{-2,11,17},{1,31,17},{-1,31,17},
		{1,30,17},{-1,30,17},{1,29,17},{-1,29,17},{1,28,17},{-1,28,17},{1,27,17},{-1,27,17},
		{40,0,16},{40,0,16},{-40,0,16},{-40,0,16},{39,0,16},{39,0,16},{-39,0,16},{-39,0,16},
		{38,0,16},{38,0,16},{-38,0,16},{-38,0,16},{37,0,16},{37,0,16},{-37,0,16},{-37,0,16},
		{36,0,16},{36,0,16},{-36,0,16},{-36,0,16},{35,0,16},{35,0,16},{-35,0,16},{-35,0,16},
		{34,0,16},{34,0,16},{-34,0,16},{-34,0,16},{33,0,16},{33,0,16},{-33,0,16},{-33,0,16},
		{32,0,16},{32,0,16},{-32,0,16},{-32,0,16},{14,1,16},{14,1,16},{-14,1,16},{-14,1,16},
		{13,1,16},{13,1,16},{-13,1,16},{-13,1,16},{12,1,16},{12,1,16},{-12,1,16},{-12,1,16},
		{11,1,16},{11,1,16},{-11,1,16},{-11,1,16},{10,1,16},{10,1,16},{-10,1,16},{-10,1,16},
		{9,1,16},{9,1,16},{-9,1,16},{-9,1,16},{8,1,16},{8,1,16},{-8,1,16},{-8,1,16},
		{31,0,15},{31,0,15},{31,0,15},{31,0,15},{-31,0,15},{-31,0,15},{-31,0,15},{-31,0,15},
		{30,0,15},{30,0,15},{30,0,15},{30,0,15},{-30,0,15},{-30,0,15},{-30,0,15},{-30,0,15},
		{29,0,15},{29,0,15},{29,0,15},{29,0,15},{-29,0,15},{-29,0,15},{-29,0,15},{-29,0,15},
		{28,0,15},{28,0,15},{28,0,15},{28,0,15},{-28,0,15},{-28,0,15},{-28,0,15},{-28,0,15},
		{27,0,15},{27,0,15},{27,0,15},{27,0,15},{-27,0,15},{-27,0,15},{-27,0,15},{-27,0,15},
		{26,0,15},{26,0,15},{26,0,15},{26,0,15},{-26,0,15},{-26,0,15},{-26,0,15},{-26,0,15},
		{25,0,15},{25,0,15},{25,0,15},{25,0,15},{-25,0,15},{-25,0,15},{-25,0,15},{-25,0,15},
		{24,0,15},{24,0,15},{24,0,15},{24,0,15},{-24,0,15},{-24,0,15},{-24,0,15},{-24,0,15},
		{23,0,15},{23,0,15},{23,0,15},{23,0,15},{-23,0,15},{-23,0,15},{-23,0,15},{-23,0,15},
		{22,0,15},{22,0,15},{22,0,15},{22,0,15},{-22,0,15},{-22,0,15},{-22,0,15},{-22,0,15},
		{21,0,15},{21,0,15},{21,0,15},{21,0,15},{-21,0,15},{-21,0,15},{-21,0,15},{-21,0,15},
		{20,0,15},{20,0,15},{20,0,15},{20,0,15},{-20,0,15},{-20,0,15},{-20,0,15},{-20,0,15},
		{19,0,15},{19,0,15},{19,0,15},{19,0,15},{-19,0,15},{-19,0,15},{-19,0,15},{-19,0,15},
		{18,0,15},{18,0,15},{18,0,15},{18,0,15},{-18,0,15},{-18,0,15},{-18,0,15},{-18,0,15},
		{17,0,15},{17,0,15},{17,0,15},{17,0,15},{-17,0,15},{-17,0,15},{-17,0,15},{-17,0,15},
		{16,0,15},{16,0,15},{16,0,15},{16,0,15},{-16,0,15},{-16,0,15},{-16,0,15},{-16,0,15},
		{2,10,14},{2,10,14},{2,10,14},{2,10,14},{2,10,14},{2,10,14},{2,10,14},{2,10,14},
		{-2,10,14},{-2,10,14},{-2,10,14},{-2,10,14},{-2,10,14},{-2,10,14},{-2,10,14},{-2,10,14},
		{2,9,14},{2,9,14},{2,9,14},{2,9,14},{2,9,14},{2,9,14},{2,9,14},{2,9,14},
		{-2,9,14},{-2,9,14},{-2,9,14},{-2,9,14},{-2,9,14},{-2,9,14},{-2,9,14},{-2,9,14},
		{3,5,14},{3,5,14},{3,5,14},{3,5,14},{3,5,14},{3,5,14},{3,5,14},{3,5,14},
		{-3,5,14},{-3,5,14},{-3,5,14},{-3,5,14},{-3,5,14},{-3,5,14},{-3,5,14},{-3,5,14},
		{4,3,14},{4,3,14},{4,3,14},{4,3,14},{4,3,14},{4,3,14},{4,3,14},{4,3,14},
		{-4,3,14},{-4,3,14},{-4,3,14},{-4,3,14},{-4,3,14},{-4,3,14},{-4,3,14},{-4,3,14},
		{5,2,14},{5,2,14},{5,2,14},{5,2,14},{5,2,14},{5,2,14},{5,2,14},{5,2,14},
		{-5,2,14},{-5,2,14},{-5,2,14},{-5,2,14},{-5,2,14},{-5,2,14},{-5,2,14},{-5,2,14},
		{7,1,14},{7,1,14},{7,1,14},{7,1,14},{7,1,14},{7,1,14},{7,1,14},{7,1,14},
		{-7,1,14},{-7,1,14},{-7,1,14},{-7,1,14},{-7,1,14},{-7,1,14},{-7,1,14},{-7,1,14},
		{6,1,14},{6,1,14},{6,1,14},{6,1,14},{6,1,14},{6,1,14},{6,1,14},{6,1,14},
		{-6,1,14},{-6,1,14},{-6,1,14},{-6,1,14},{-6,1,14},{-6,1,14},{-6,1,14},{-6,1,14},
		{15,0,14},{15,0,14},{15,0,14},{15,0,14},{15,0,14},{15,0,14},{15,0,14},{15,0,14},
		{-15,0,14},{-15,0,14},{-15,0,14},{-15,0,14},{-15,0,14},{-15,0,14},{-15,0,14},{-15,0,14},
		{14,0,14},{14,0,14},{14,0,14},{14,0,14},{14,0,14},{14,0,14},{14,0,14},{14,0,14},
		{-14,0,14},{-14,0,14},{-14,0,14},{-14,0,14},{-14,0,14},{-14,0,14},{-14,0,14},{-14,0,14},
		{13,0,14},{13,0,14},{13,0,14},{13,0,14},{13,0,14},{13,0,14},{13,0,14},{13,0,14},
		{-13,0,14},{-13,0,14},{-13,0,14},{-13,0,14},{-13,0,14},{-13,0,14},{-13,0,14},{-13,0,14},
		{12,0,14},{12,0,14},{12,0,14},{12,0,14},{12,0,14},{12,0,14},{12,0,14},{12,0,14},
		{-12,0,14},{-12,0,14},{-12,0,14},{-12,0,14},{-12,0,14},{-12,0,14},{-12,0,14},{-12,0,14},
		{1,26,14},{1,26,14},{1,26,14},{1,26,14},{1,26,14},{1,26,14},{1,26,14},{1,26,14},
		{-1,26,14},{-1,26,14},{-1,26,14},{-1,26,14},{-1,26,14},{-1,26,14},{-1,26,14},{-1,26,14},
		{1,25,14},{1,25,14},{1,25,14},{1,25,14},{1,25,14},{1,25,14},{1,25,14},{1,25,14},
		{-1,25,14},{-1,25,14},{-1,25,14},{-1,25,14},{-1,25,14},{-1,25,14},{-1,25,14},{-1,25,14},
		{1,24,14},{1,24,14},{1,24,14},{1,24,14},{1,24,14},{1,24,14},{1,24,14},{1,24,14},
		{-1,24,14},{-1,24,14},{-1,24,14},{-1,24,14},{-1,24,14},{-1,24,14},{-1,24,14},{-1,24,14},
		{1,23,14},{1,23,14},{1,23,14},{1,23,14},{1,23,14},{1,23,14},{1,23,14},{1,23,14},
		{-1,23,14},{-1,23,14},{-1,23,14},{-1,23,14},{-1,23,14},{-1,23,14},{-1,23,14},{-1,23,14},
		{1,22,14},{1,22,14},{1,22,14},{1,22,14},{1,22,14},{1,22,14},{1,22,14},{1,22,14},
		{-1,22,14},{-1,22,14},{-1,22,14},{-1,22,14},{-1,22,14},{-1,22,14},{-1,22,14},{-1,22,14},
		{11,0,13},{11,0,13},{11,0,13},{11,0,13},{11,0,13},{11,0,13},{11,0,13},{11,0,13},
		{11,0,13},{11,0,13},{11,0,13},{11,0,13},{11,0,13},{11,0,13},{11,0,13},{11,0,13},
		{-11,0,13},{-11,0,13},{-11,0,13},{-11,0,13},{-11,0,13},{-11,0,13},{-11,0,13},{-11,0,13},
		{-11,0,13},{-11,0,13},{-11,0,13},{-11,0,13},{-11,0,13},{-11,0,13},{-11,0,13},{-11,0,13},
		{2,8,13},{2,8,13},{2,8,13},{2,8,13},{2,8,13},{2,8,13},{2,8,13},{2,8,13},
		{2,8,13},{2,8,13},{2,8,13},{2,8,13},{2,8,13},{2,8,13},{2,8,13},{2,8,13},
		{-2,8,13},{-2,8,13},{-2,8,13},{-2,8,13},{-2,8,13},{-2,8,13},{-2,8,13},{-2,8,13},
		{-2,8,13},{-2,8,13},{-2,8,13},{-2,8,13},{-2,8,13},{-2,8,13},{-2,8,13},{-2,8,13},
		{3,4,13},{3,4,13},{3,4,13},{3,4,13},{3,4,13},{3,4,13},{3,4,13},{3,4,13},
		{3,4,13},{3,4,13},{3,4,13},{3,4,13},{3,4,13},{3,4,13},{3,4,13},{3,4,13},
		{-3,4,13},{-3,4,13},{-3,4,13},{-3,4,13},{-3,4,13},{-3,4,13},{-3,4,13},{-3,4,13},
		{-3,4,13},{-3,4,13},{-3,4,13},{-3,4,13},{-3,4,13},{-3,4,13},{-3,4,13},{-3,4,13},
		{10,0,13},{10,0,13},{10,0,13},{10,0,13},{10,0,13},{10,0,13},{10,0,13},{10,0,13},
		{10,0,13},{10,0,13},{10,0,13},{10,0,13},{10,0,13},{10,0,13},{10,0,13},{10,0,13},
		{-10,0,13},{-10,0,13},{-10,0,13},{-10,0,13},{-10,0,13},{-10,0,13},{-10,0,13},{-10,0,13},
		{-10,0,13},{-10,0,13},{-10,0,13},{-10,0,13},{-10,0,13},{-10,0,13},{-10,0,13},{-10,0,13},
		{4,2,13},{4,2,13},{4,2,13},{4,2,13},{4,2,13},{4,2,13},{4,2,13},{4,2,13},
		{4,2,13},{4,2,13},{4,2,13},{4,2,13},{4,2,13},{4,2,13},{4,2,13},{4,2,13},
		{-4,2,13},{-4,2,13},{-4,2,13},{-4,2,13},{-4,2,13},{-4,2,13},{-4,2,13},{-4,2,13},
		{-4,2,13},{-4,2,13},{-4,2,13},{-4,2,13},{-4,2,13},{-4,2,13},{-4,2,13},{-4,2,13},
		{2,7,13},{2,7,13},{2,7,13},{2,7,13},{2,7,13},{2,7,13},{2,7,13},{2,7,13},
		{2,7,13},{2,7,13},{2,7,13},{2,7,13},{2,7,13},{2,7,13},{2,7,13},{2,7,13},
		{-2,7,13},{-2,7,13},{-2,7,13},{-2,7,13},{-2,7,13},{-2,7,13},{-2,7,13},{-2,7,13},
		{-2,7,13},{-2,7,13},{-2,7,13},{-2,7,13},{-2,7,13},{-2,7,13},{-2,7,13},{-2,7,13},
		{1,21,13},{1,21,13},{1,21,13},{1,21,13},{1,21,13},{1,21,13},{1,21,13},{1,21,13},
		{1,21,13},{1,21,13},{1,21,13},{1,21,13},{1,21,13},{1,21,13},{1,21,13},{1,21,13},
		{-1,21,13},{-1,21,13},{-1,21,13},{-1,21,13},{-1,21,13},{-1,21,13},{-1,21,13},{-1,21,13},
		{-1,21,13},{-1,21,13},{-1,21,13},{-1,21,13},{-1,21,13},{-1,21,13},{-1,21,13},{-1,21,13},
		{1,20,13},{1,20,13},{1,20,13},{1,20,13},{1,20,13},{1,20,13},{1,20,13},{1,20,13},
		{1,20,13},{1,20,13},{1,20,13},{1,20,13},{1,20,13},{1,20,13},{1,20,13},{1,20,13},
		{-1,20,13},{-1,20,13},{-1,20,13},{-1,20,13},{-1,20,13},{-1,20,13},{-1,20,13},{-1,20,13},
		{-1,20,13},{-1,20,13},{-1,20,13},{-1,20,13},{-1,20,13},{-1,20,13},{-1,20,13},{-1,20,13},
		{9,0,13},{9,0,13},{9,0,13},{9,0,13},{9,0,13},{9,0,13},{9,0,13},{9,0,13},
		{9,0,13},{9,0,13},{9,0,13},{9,0,13},{9,0,13},{9,0,13},{9,0,13},{9,0,13},
		{-9,0,13},{-9,0,13},{-9,0,13},{-9,0,13},{-9,0,13},{-9,0,13},{-9,0,13},{-9,0,13},
		{-9,0,13},{-9,0,13},{-9,0,13},{-9,0,13},{-9,0,13},{-9,0,13},{-9,0,13},{-9,0,13},
		{1,19,13},{1,19,13},{1,19,13},{1,19,13},{1,19,13},{1,19,13},{1,19,13},{1,19,13},
		{1,19,13},{1,19,13},{1,19,13},{1,19,13},{1,19,13},{1,19,13},{1,19,13},{1,19,13},
		{-1,19,13},{-1,19,13},{-1,19,13},{-1,19,13},{-1,19,13},{-1,19,13},{-1,19,13},{-1,19,13},
		{-1,19,13},{-1,19,13},{-1,19,13},{-1,19,13},{-1,19,13},{-1,19,13},{-1,19,13},{-1,19,13},
		{1,18,13},{1,18,13},{1,18,13},{1,18,13},{1,18,13},{1,18,13},{1,18,13},{1,18,13},
		{1,18,13},{1,18,13},{1,18,13},{1,18,13},{1,18,13},{1,18,13},{1,18,13},{1,18,13},
		{-1,18,13},{-1,18,13},{-1,18,13},{-1,18,13},{-1,18,13},{-1,18,13},{-1,18,13},{-1,18,13},
		{-1,18,13},{-1,18,13},{-1,18,13},{-1,18,13},{-1,18,13},{-1,18,13},{-1,18,13},{-1,18,13},
		{5,1,13},{5,1,13},{5,1,13},{5,1,13},{5,1,13},{5,1,13},{5,1,13},{5,1,13},
		{5,1,13},{5,1,13},{5,1,13},{5,1,13},{5,1,13},{5,1,13},{5,1,13},{5,1,13},
		{-5,1,13},{-5,1,13},{-5,1,13},{-5,1,13},{-5,1,13},{-5,1,13},{-5,1,13},{-5,1,13},
		{-5,1,13},{-5,1,13},{-5,1,13},{-5,1,13},{-5,1,13},{-5,1,13},{-5,1,13},{-5,1,13},
		{3,3,13},{3,3,13},{3,3,13},{3,3,13},{3,3,13},{3,3,13},{3,3,13},{3,3,13},
		{3,3,13},{3,3,13},{3,3,13},{3,3,13},{3,3,13},{3,3,13},{3,3,13},{3,3,13},
		{-3,3,13},{-3,3,13},{-3,3,13},{-3,3,13},{-3,3,13},{-3,3,13},{-3,3,13},{-3,3,13},
		{-3,3,13},{-3,3,13},{-3,3,13},{-3,3,13},{-3,3,13},{-3,3,13},{-3,3,13},{-3,3,13},
		{8,0,13},{8,0,13},{8,0,13},{8,0,13},{8,0,13},{8,0,13},{8,0,13},{8,0,13},
		{8,0,13},{8,0,13},{8,0,13},{8,0,13},{8,0,13},{8,0,13},{8,0,13},{8,0,13},
		{-8,0,13},{-8,0,13},{-8,0,13},{-8,0,13},{-8,0,13},{-8,0,13},{-8,0,13},{-8,0,13},
		{-8,0,13},{-8,0,13},{-8,0,13},{-8,0,13},{-8,0,13},{-8,0,13},{-8,0,13},{-8,0,13},
		{2,6,13},{2,6,13},{2,6,13},{2,6,13},{2,6,13},{2,6,13},{2,6,13},{2,6,13},
		{2,6,13},{2,6,13},{2,6,13},{2,6,13},{2,6,13},{2,6,13},{2,6,13},{2,6,13},
		{-2,6,13},{-2,6,13},{-2,6,13},{-2,6,13},{-2,6,13},{-2,6,13},{-2,6,13},{-2,6,13},
		{-2,6,13},{-2,6,13},{-2,6,13},{-2,6,13},{-2,6,13},{-2,6,13},{-2,6,13},{-2,6,13},
		{1,17,13},{1,17,13},{1,17,13},{1,17,13},{1,17,13},{1,17,13},{1,17,13},{1,17,13},
		{1,17,13},{1,17,13},{1,17,13},{1,17,13},{1,17,13},{1,17,13},{1,17,13},{1,17,13},
		{-1,17,13},{-1,17,13},{-1,17,13},{-1,17,13},{-1,17,13},{-1,17,13},{-1,17,13},{-1,17,13},
		{-1,17,13},{-1,17,13},{-1,17,13},{-1,17,13},{-1,17,13},{-1,17,13},{-1,17,13},{-1,17,13},
		{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},
		{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},
		{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},
		{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},
		{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},
		{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},
		{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},
		{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},{1,16,11},
		{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},
		{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},
		{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},
		{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},
		{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},
		{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},
		{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},
		{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},{-1,16,11},
		{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},
		{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},
		{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},
		{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},
		{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},
		{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},
		{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},
		{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},{2,5,11},
		{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},
		{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},
		{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},
		{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},
		{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},
		{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},
		{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},
		{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},{-2,5,11},
		{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},
		{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},
		{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},
		{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},
		{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},
		{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},
		{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},
		{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},{7,0,11},
		{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},
		{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},
		{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},
		{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},
		{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},
		{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},
		{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},
		{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},{-7,0,11},
		{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},
		{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},
		{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},
		{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},
		{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},
		{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},
		{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},
		{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},{3,2,11},
		{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},
		{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},
		{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},
		{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},
		{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},
		{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},
		{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},
		{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},{-3,2,11},
		{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},
		{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},
		{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},
		{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},
		{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},
		{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},
		{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},
		{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},{4,1,11},
		{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},
		{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},
		{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},
		{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},
		{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},
		{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},
		{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},
		{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},{-4,1,11},
		{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},
		{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},
		{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},
		{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},
		{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},
		{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},
		{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},
		{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},{1,15,11},
		{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},
		{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},
		{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},
		{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},
		{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},
		{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},
		{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},
		{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},{-1,15,11},
		{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},
		{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},
		{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},
		{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},
		{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},
		{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},
		{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},
		{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},{1,14,11},
		{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},
		{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},
		{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},
		{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},
		{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},
		{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},
		{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},
		{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},{-1,14,11},
		{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},
		{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},
		{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},
		{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},
		{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},
		{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},
		{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},
		{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},{2,4,11},
		{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},
		{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},
		{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},
		{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},
		{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},
		{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},
		{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},
		{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},{-2,4,11},
	};

	code = read_bits(in, 17);
	code -= 32;

	*run = table[code].run;
	*level = table[code].level;
	
	erase_bits(in, table[code].length);

	return 1;
}
