/*******************************************************************
               DCT coefficient table 'B-15' module
 *******************************************************************/

#define B15_C
#include "b15.h"

int read_dct_coefficient_b15(VIDEO_STREAM *in, int *run, int *level);

static int eob(VIDEO_STREAM *in, int *run, int *level);
static int esc(VIDEO_STREAM *in, int *run, int *level);
static int l9b(VIDEO_STREAM *in, int *run, int *level);
static int o9b(VIDEO_STREAM *in, int *run, int *level);

int read_dct_coefficient_b15(VIDEO_STREAM *in, int *run, int *level)
{
	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,
		eob, eob, eob, eob, 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, l9b, l9b, l9b, l9b, l9b, l9b,
	};

	code = vs_read_bits(in, 6);

	return table[code](in, run, level);
}
		
static int eob(VIDEO_STREAM *in, int *run, int *level)
{
	vs_erase_bits(in, 4);

	return 0;
}

static int esc(VIDEO_STREAM *in, int *run, int *level)
{
	vs_erase_bits(in, 6);

	read_fixed_length_dct_coefficient(in, run, level);

	return 1;
}

static int l9b(VIDEO_STREAM *in, int *run, int *level)
{
	int code;

	static const DCT_COEFFICIENT_VLC_ELEMENT table[] = {
		{1,7,8},{1,7,8},{-1,7,8},{-1,7,8},{1,8,8},{1,8,8},{-1,8,8},{-1,8,8},
		{1,6,8},{1,6,8},{-1,6,8},{-1,6,8},{2,2,8},{2,2,8},{-2,2,8},{-2,2,8},
		{7,0,7},{7,0,7},{7,0,7},{7,0,7},{-7,0,7},{-7,0,7},{-7,0,7},{-7,0,7},
		{6,0,7},{6,0,7},{6,0,7},{6,0,7},{-6,0,7},{-6,0,7},{-6,0,7},{-6,0,7},
		{1,4,7},{1,4,7},{1,4,7},{1,4,7},{-1,4,7},{-1,4,7},{-1,4,7},{-1,4,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},
		{5,1,9},{-5,1,9},{1,11,9},{-1,11,9},{11,0,9},{-11,0,9},{10,0,9},{-10,0,9},
		{1,13,9},{-1,13,9},{1,12,9},{-1,12,9},{2,3,9},{-2,3,9},{4,1,9},{-4,1,9},
		{1,2,6},{1,2,6},{1,2,6},{1,2,6},{1,2,6},{1,2,6},{1,2,6},{1,2,6},
		{-1,2,6},{-1,2,6},{-1,2,6},{-1,2,6},{-1,2,6},{-1,2,6},{-1,2,6},{-1,2,6},
		{2,1,6},{2,1,6},{2,1,6},{2,1,6},{2,1,6},{2,1,6},{2,1,6},{2,1,6},
		{-2,1,6},{-2,1,6},{-2,1,6},{-2,1,6},{-2,1,6},{-2,1,6},{-2,1,6},{-2,1,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},
		{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,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},
		{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},
		{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},
		{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},
		{3,0,5},{3,0,5},{3,0,5},{3,0,5},{3,0,5},{3,0,5},{3,0,5},{3,0,5},
		{3,0,5},{3,0,5},{3,0,5},{3,0,5},{3,0,5},{3,0,5},{3,0,5},{3,0,5},
		{-3,0,5},{-3,0,5},{-3,0,5},{-3,0,5},{-3,0,5},{-3,0,5},{-3,0,5},{-3,0,5},
		{-3,0,5},{-3,0,5},{-3,0,5},{-3,0,5},{-3,0,5},{-3,0,5},{-3,0,5},{-3,0,5},
		{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},
		{2,0,4},{2,0,4},{2,0,4},{2,0,4},{2,0,4},{2,0,4},{2,0,4},{2,0,4},
		{2,0,4},{2,0,4},{2,0,4},{2,0,4},{2,0,4},{2,0,4},{2,0,4},{2,0,4},
		{2,0,4},{2,0,4},{2,0,4},{2,0,4},{2,0,4},{2,0,4},{2,0,4},{2,0,4},
		{2,0,4},{2,0,4},{2,0,4},{2,0,4},{2,0,4},{2,0,4},{2,0,4},{2,0,4},
		{-2,0,4},{-2,0,4},{-2,0,4},{-2,0,4},{-2,0,4},{-2,0,4},{-2,0,4},{-2,0,4},
		{-2,0,4},{-2,0,4},{-2,0,4},{-2,0,4},{-2,0,4},{-2,0,4},{-2,0,4},{-2,0,4},
		{-2,0,4},{-2,0,4},{-2,0,4},{-2,0,4},{-2,0,4},{-2,0,4},{-2,0,4},{-2,0,4},
		{-2,0,4},{-2,0,4},{-2,0,4},{-2,0,4},{-2,0,4},{-2,0,4},{-2,0,4},{-2,0,4},
		{4,0,6},{4,0,6},{4,0,6},{4,0,6},{4,0,6},{4,0,6},{4,0,6},{4,0,6},
		{-4,0,6},{-4,0,6},{-4,0,6},{-4,0,6},{-4,0,6},{-4,0,6},{-4,0,6},{-4,0,6},
		{5,0,6},{5,0,6},{5,0,6},{5,0,6},{5,0,6},{5,0,6},{5,0,6},{5,0,6},
		{-5,0,6},{-5,0,6},{-5,0,6},{-5,0,6},{-5,0,6},{-5,0,6},{-5,0,6},{-5,0,6},
		{1,9,8},{1,9,8},{-1,9,8},{-1,9,8},{3,1,8},{3,1,8},{-3,1,8},{-3,1,8},
		{1,10,8},{1,10,8},{-1,10,8},{-1,10,8},{8,0,8},{8,0,8},{-8,0,8},{-8,0,8},
		{9,0,8},{9,0,8},{-9,0,8},{-9,0,8},{12,0,9},{-12,0,9},{13,0,9},{-13,0,9},
		{3,2,9},{-3,2,9},{2,4,9},{-2,4,9},{14,0,9},{-14,0,9},{15,0,9},{-15,0,9},
	};

	code = vs_read_bits(in, 9);
	code -= 16;

	*run = table[code].run;
	*level = table[code].level;

	vs_erase_bits(in, table[code].length);

	return 1;
}

static int o9b(VIDEO_STREAM *in, int *run, int *level)
{
	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},
		{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},
		{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},
		{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},
		{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},
		{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},
		{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},
		{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},
		{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},
		{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},
		{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},
		{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},
		{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},
		{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},
		{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},
		{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},
		{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},{2,5,10},
		{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},
		{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},
		{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},
		{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},
		{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},
		{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},
		{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},
		{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},
		{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},
		{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},
		{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},
		{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},
		{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},
		{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},
		{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},
		{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},{-2,5,10},
		{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},
		{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},
		{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},
		{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},
		{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},
		{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},
		{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},
		{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},
		{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},
		{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},
		{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},
		{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},
		{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},
		{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},
		{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},
		{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},{1,14,10},
		{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},
		{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},
		{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},
		{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},
		{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},
		{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},
		{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},
		{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},
		{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},
		{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},
		{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},
		{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},
		{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},
		{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},
		{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},
		{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},{-1,14,10},
		{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},
		{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},
		{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},
		{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},
		{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},
		{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},
		{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},
		{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},{4,2,11},
		{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},
		{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},
		{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},
		{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},
		{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},
		{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},
		{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},
		{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,11},{-4,2,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},{-1,16,11},
		{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},
		{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},
		{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},
		{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},
		{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},
		{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},
		{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},
		{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},
		{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},
		{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},
		{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},
		{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},
		{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},
		{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},
		{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},
		{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},{1,15,10},
		{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},
		{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},
		{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},
		{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},
		{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},
		{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},
		{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},
		{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},
		{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},
		{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},
		{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},
		{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},
		{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},
		{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},
		{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},
		{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},{-1,15,10},
	};

	code = vs_read_bits(in, 17);
	code -= 32;

	*run = table[code].run;
	*level = table[code].level;

	vs_erase_bits(in, table[code].length);

	return 1;
}
