(** AUTHOR "Yves Weber";
	PURPOSE "Lookup Tables for the MPEGUtilities and MPEGVideoDecoder modules";
*)
MODULE MPEGTables;

VAR
	(* zig-zag scanning order *)
	ZZ*: ARRAY 8 OF ARRAY 8 OF LONGINT;
	ZZN*: ARRAY 64 OF LONGINT;

	(* default intra quantizer matrix *)
	IQM*: ARRAY 64 OF LONGINT;

	(* coded blocks pattern codes *)
	CBP7*: ARRAY 112 OF ARRAY 2 OF LONGINT;	(* table with coded blocks pattern (code length 3..7 bit) *)
	CBP9*: ARRAY 64 OF ARRAY 2 OF LONGINT;		(* table with coded blocks pattern (code length 8..9 bit) *)

	(* motion codes *)
	MC4*: ARRAY 8 OF ARRAY 2 OF LONGINT;		(* table with motion codes (code length 1..4) *)
	MC7*: ARRAY 8 OF ARRAY 2 OF LONGINT;		(* table with motion codes (code length 5..7) *)
	MC10*: ARRAY 12 OF ARRAY 2 OF LONGINT;		(* table with motion codes (code length 8..9) *)

	(* DC (= first DCT coefficient) code lengths *)
	DCL3*: ARRAY 7 OF ARRAY 2 OF LONGINT;		(* table with DC code lengths for luminance *)
	DCC3*: ARRAY 7 OF ARRAY 2 OF LONGINT;		(* table with DC code lengths for chrominance *)

	(* run/level codes *)
	RLC6*: ARRAY 11 OF ARRAY 3 OF LONGINT;		(* run/level codes of length 4..6 *)
	RLC8*: ARRAY 12 OF ARRAY 3 OF LONGINT;		(* run/level codes of length 7..8 *)
	RLC9*: ARRAY 8 OF ARRAY 2 OF LONGINT;		(* run/level codes of length 9 *)
	RLC11*: ARRAY 8 OF ARRAY 2 OF LONGINT;		(* run/level codes of length 11 *)
	RLC13*: ARRAY 16 OF ARRAY 2 OF LONGINT;	(* run/level codes of length 13 *)
	RLC14*: ARRAY 16 OF ARRAY 2 OF LONGINT;	(* run/level codes of length 14 *)
	RLC16*: ARRAY 16 OF ARRAY 2 OF LONGINT;	(* run/level codes of length 16 *)
	RLC17*: ARRAY 16 OF ARRAY 2 OF LONGINT;	(* run/level codes of length 17 *)

	(* run/level codes - second version (available in MPEG-2 only) *)
	RLC8_2*: ARRAY 12 OF ARRAY 3 OF LONGINT;	(* run/level codes of length 7..8 *)
	RLC9_2*: ARRAY 8 OF ARRAY 2 OF LONGINT;		(* run/level codes of length 9 (first part) *)
	RLC9_2_2*: ARRAY 16 OF ARRAY 3 OF LONGINT;	(* run/level codes of length 9 (second part) *)

	(* quantiser scales - MPEG-2 only *)
	QS0*: ARRAY 32 OF LONGINT;					(* table 0 *)
	QS1*: ARRAY 32 OF LONGINT;					(* table 1 *)

	(* DC predictions for the various precisions available - MPEG-2 only *)
	DCP*: ARRAY 4 OF LONGINT;

	(* DC multiplier for intra-coded blocks for the various precisions available - MPEG-2 only *)
	DCM*: ARRAY 4 OF LONGINT;

	(* Line numbers for field-based blocks *)
	FBB*: ARRAY 8 OF LONGINT;

BEGIN
	(* Fill in all table values *)
	ZZ[0][0] := 00; ZZ[0][1] := 01; ZZ[0][2] := 05; ZZ[0][3] := 06; ZZ[0][4] := 14; ZZ[0][5] := 15; ZZ[0][6] := 27; ZZ[0][7] := 28;
	ZZ[1][0] := 02; ZZ[1][1] := 04; ZZ[1][2] := 07; ZZ[1][3] := 13; ZZ[1][4] := 16; ZZ[1][5] := 26; ZZ[1][6] := 29; ZZ[1][7] := 42;
	ZZ[2][0] := 03; ZZ[2][1] := 08; ZZ[2][2] := 12; ZZ[2][3] := 17; ZZ[2][4] := 25; ZZ[2][5] := 30; ZZ[2][6] := 41; ZZ[2][7] := 43;
	ZZ[3][0] := 09; ZZ[3][1] := 11; ZZ[3][2] := 18; ZZ[3][3] := 24; ZZ[3][4] := 31; ZZ[3][5] := 40; ZZ[3][6] := 44; ZZ[3][7] := 53;
	ZZ[4][0] := 10; ZZ[4][1] := 19; ZZ[4][2] := 23; ZZ[4][3] := 32; ZZ[4][4] := 39; ZZ[4][5] := 45; ZZ[4][6] := 52; ZZ[4][7] := 54;
	ZZ[5][0] := 20; ZZ[5][1] := 22; ZZ[5][2] := 33; ZZ[5][3] := 38; ZZ[5][4] := 46; ZZ[5][5] := 51; ZZ[5][6] := 55; ZZ[5][7] := 60;
	ZZ[6][0] := 21; ZZ[6][1] := 34; ZZ[6][2] := 37; ZZ[6][3] := 47; ZZ[6][4] := 50; ZZ[6][5] := 56; ZZ[6][6] := 59; ZZ[6][7] := 61;
	ZZ[7][0] := 35; ZZ[7][1] := 36; ZZ[7][2] := 48; ZZ[7][3] := 49; ZZ[7][4] := 57; ZZ[7][5] := 58; ZZ[7][6] := 62; ZZ[7][7] := 63;

	ZZN[00] := 00; ZZN[01] := 01; ZZN[02] := 08; ZZN[03] := 16; ZZN[04] := 09; ZZN[05] := 02; ZZN[06] := 03; ZZN[07] := 10;
	ZZN[08] := 17; ZZN[09] := 24; ZZN[10] := 32; ZZN[11] := 25; ZZN[12] := 18; ZZN[13] := 11; ZZN[14] := 04; ZZN[15] := 05;
	ZZN[16] := 12; ZZN[17] := 19; ZZN[18] := 26; ZZN[19] := 33; ZZN[20] := 40; ZZN[21] := 48; ZZN[22] := 41; ZZN[23] := 24;
	ZZN[24] := 27; ZZN[25] := 20; ZZN[26] := 13; ZZN[27] := 06; ZZN[28] := 07; ZZN[29] := 14; ZZN[30] := 21; ZZN[31] := 28;
	ZZN[32] := 35; ZZN[33] := 42; ZZN[34] := 49; ZZN[35] := 56; ZZN[36] := 57; ZZN[37] := 50; ZZN[38] := 43; ZZN[39] := 36;
	ZZN[40] := 29; ZZN[41] := 22; ZZN[42] := 15; ZZN[43] := 23; ZZN[44] := 30; ZZN[45] := 37; ZZN[46] := 44; ZZN[47] := 51;
	ZZN[48] := 58; ZZN[49] := 59; ZZN[50] := 52; ZZN[51] := 45; ZZN[52] := 38; ZZN[53] := 31; ZZN[54] := 39; ZZN[55] := 46;
	ZZN[56] := 53; ZZN[57] := 60; ZZN[58] := 61; ZZN[59] := 54; ZZN[60] := 47; ZZN[61] := 55; ZZN[62] := 62; ZZN[63] := 63;

	IQM[00] := 08; IQM[01] := 16; IQM[02] := 19; IQM[03] := 22; IQM[04] := 26; IQM[05] := 27; IQM[06] := 29; IQM[07] := 34;
	IQM[08] := 16; IQM[09] := 16; IQM[10] := 22; IQM[11] := 24; IQM[12] := 27; IQM[13] := 29; IQM[14] := 34; IQM[15] := 37;
	IQM[16] := 19; IQM[17] := 22; IQM[18] := 26; IQM[19] := 27; IQM[20] := 29; IQM[21] := 34; IQM[22] := 34; IQM[23] := 38;
	IQM[24] := 22; IQM[25] := 22; IQM[26] := 26; IQM[27] := 27; IQM[28] := 29; IQM[29] := 34; IQM[30] := 37; IQM[31] := 40;
	IQM[32] := 22; IQM[33] := 26; IQM[34] := 27; IQM[35] := 29; IQM[36] := 32; IQM[37] := 35; IQM[38] := 40; IQM[39] := 48;
	IQM[40] := 26; IQM[41] := 27; IQM[42] := 29; IQM[43] := 32; IQM[44] := 35; IQM[45] := 40; IQM[46] := 48; IQM[47] := 58;
	IQM[48] := 26; IQM[49] := 27; IQM[50] := 29; IQM[51] := 34; IQM[52] := 38; IQM[53] := 46; IQM[54] := 56; IQM[55] := 69;
	IQM[56] := 27; IQM[57] := 29; IQM[58] := 35; IQM[59] := 38; IQM[60] := 46; IQM[61] := 56; IQM[62] := 69; IQM[63] := 83;

	(* first index: 7bit code read from stream; second index: 0->pattern, 1->code length *)
	CBP7[000][0] := 34; CBP7[000][1] := 7; CBP7[001][0] := 18; CBP7[001][1] := 7; CBP7[002][0] := 10; CBP7[002][1] := 7;
	CBP7[003][0] := 06; CBP7[003][1] := 7; CBP7[004][0] := 33; CBP7[004][1] := 7; CBP7[005][0] := 17; CBP7[005][1] := 7;
	CBP7[006][0] := 09; CBP7[006][1] := 7; CBP7[007][0] := 05; CBP7[007][1] := 7; CBP7[008][0] := 63; CBP7[008][1] := 6;
	CBP7[009][0] := 63; CBP7[009][1] := 6; CBP7[010][0] := 03; CBP7[010][1] := 6; CBP7[011][0] := 03; CBP7[011][1] := 6;
	CBP7[012][0] := 36; CBP7[012][1] := 6; CBP7[013][0] := 36; CBP7[013][1] := 6; CBP7[014][0] := 24; CBP7[014][1] := 6;
	CBP7[015][0] := 24; CBP7[015][1] := 6; CBP7[016][0] := 62; CBP7[016][1] := 5; CBP7[017][0] := 62; CBP7[017][1] := 5;
	CBP7[018][0] := 62; CBP7[018][1] := 5; CBP7[019][0] := 62; CBP7[019][1] := 5; CBP7[020][0] := 02; CBP7[020][1] := 5;
	CBP7[021][0] := 02; CBP7[021][1] := 5; CBP7[022][0] := 02; CBP7[022][1] := 5; CBP7[023][0] := 02; CBP7[023][1] := 5;
	CBP7[024][0] := 61; CBP7[024][1] := 5; CBP7[025][0] := 61; CBP7[025][1] := 5; CBP7[026][0] := 61; CBP7[026][1] := 5;
	CBP7[027][0] := 61; CBP7[027][1] := 5; CBP7[028][0] := 01; CBP7[028][1] := 5; CBP7[029][0] := 01; CBP7[029][1] := 5;
	CBP7[030][0] := 01; CBP7[030][1] := 5; CBP7[031][0] := 01; CBP7[031][1] := 5; CBP7[032][0] := 56; CBP7[032][1] := 5;
	CBP7[033][0] := 56; CBP7[033][1] := 5; CBP7[034][0] := 56; CBP7[034][1] := 5; CBP7[035][0] := 56; CBP7[035][1] := 5;
	CBP7[036][0] := 52; CBP7[036][1] := 5; CBP7[037][0] := 52; CBP7[037][1] := 5; CBP7[038][0] := 52; CBP7[038][1] := 5;
	CBP7[039][0] := 52; CBP7[039][1] := 5; CBP7[040][0] := 44; CBP7[040][1] := 5; CBP7[041][0] := 44; CBP7[041][1] := 5;
	CBP7[042][0] := 44; CBP7[042][1] := 5; CBP7[043][0] := 44; CBP7[043][1] := 5; CBP7[044][0] := 28; CBP7[044][1] := 5;
	CBP7[045][0] := 28; CBP7[045][1] := 5; CBP7[046][0] := 28; CBP7[046][1] := 5; CBP7[047][0] := 28; CBP7[047][1] := 5;
	CBP7[048][0] := 40; CBP7[048][1] := 5; CBP7[049][0] := 40; CBP7[049][1] := 5; CBP7[050][0] := 40; CBP7[050][1] := 5;
	CBP7[051][0] := 40; CBP7[051][1] := 5; CBP7[052][0] := 20; CBP7[052][1] := 5; CBP7[053][0] := 20; CBP7[053][1] := 5;
	CBP7[054][0] := 20; CBP7[054][1] := 5; CBP7[055][0] := 20; CBP7[055][1] := 5; CBP7[056][0] := 48; CBP7[056][1] := 5;
	CBP7[057][0] := 48; CBP7[057][1] := 5; CBP7[058][0] := 48; CBP7[058][1] := 5; CBP7[059][0] := 48; CBP7[059][1] := 5;
	CBP7[060][0] := 12; CBP7[060][1] := 5; CBP7[061][0] := 12; CBP7[061][1] := 5; CBP7[062][0] := 12; CBP7[062][1] := 5;
	CBP7[063][0] := 12; CBP7[063][1] := 5; CBP7[064][0] := 32; CBP7[064][1] := 4; CBP7[065][0] := 32; CBP7[065][1] := 4;
	CBP7[066][0] := 32; CBP7[066][1] := 4; CBP7[067][0] := 32; CBP7[067][1] := 4; CBP7[068][0] := 32; CBP7[068][1] := 4;
	CBP7[069][0] := 32; CBP7[069][1] := 4; CBP7[070][0] := 32; CBP7[070][1] := 4; CBP7[071][0] := 32; CBP7[071][1] := 4;
	CBP7[072][0] := 16; CBP7[072][1] := 4; CBP7[073][0] := 16; CBP7[073][1] := 4; CBP7[074][0] := 16; CBP7[074][1] := 4;
	CBP7[075][0] := 16; CBP7[075][1] := 4; CBP7[076][0] := 16; CBP7[076][1] := 4; CBP7[077][0] := 16; CBP7[077][1] := 4;
	CBP7[078][0] := 16; CBP7[078][1] := 4; CBP7[079][0] := 16; CBP7[079][1] := 4; CBP7[080][0] := 08; CBP7[080][1] := 4;
	CBP7[081][0] := 08; CBP7[081][1] := 4; CBP7[082][0] := 08; CBP7[082][1] := 4; CBP7[083][0] := 08; CBP7[083][1] := 4;
	CBP7[084][0] := 08; CBP7[084][1] := 4; CBP7[085][0] := 08; CBP7[085][1] := 4; CBP7[086][0] := 08; CBP7[086][1] := 4;
	CBP7[087][0] := 08; CBP7[087][1] := 4; CBP7[088][0] := 04; CBP7[088][1] := 4; CBP7[089][0] := 04; CBP7[089][1] := 4;
	CBP7[090][0] := 04; CBP7[090][1] := 4; CBP7[091][0] := 04; CBP7[091][1] := 4; CBP7[092][0] := 04; CBP7[092][1] := 4;
	CBP7[093][0] := 04; CBP7[093][1] := 4; CBP7[094][0] := 04; CBP7[094][1] := 4; CBP7[095][0] := 04; CBP7[095][1] := 4;
	CBP7[096][0] := 60; CBP7[096][1] := 3; CBP7[097][0] := 60; CBP7[097][1] := 3; CBP7[098][0] := 60; CBP7[098][1] := 3;
	CBP7[099][0] := 60; CBP7[099][1] := 3; CBP7[100][0] := 60; CBP7[100][1] := 3; CBP7[101][0] := 60; CBP7[101][1] := 3;
	CBP7[102][0] := 60; CBP7[102][1] := 3; CBP7[103][0] := 60; CBP7[103][1] := 3; CBP7[104][0] := 60; CBP7[104][1] := 3;
	CBP7[105][0] := 60; CBP7[105][1] := 3; CBP7[106][0] := 60; CBP7[106][1] := 3; CBP7[107][0] := 60; CBP7[107][1] := 3;
	CBP7[108][0] := 60; CBP7[108][1] := 3; CBP7[109][0] := 60; CBP7[109][1] := 3; CBP7[110][0] := 60; CBP7[110][1] := 3;
	CBP7[111][0] := 60; CBP7[111][1] := 3;

	(* first index: 9bit code read from stream; second index: 0->pattern, 1->code length *)
	CBP9[000][0] := 00; CBP9[000][1] := 9; CBP9[001][0] := 00; CBP9[001][1] := 9; CBP9[002][0] := 39; CBP9[002][1] := 9;
	CBP9[003][0] := 27; CBP9[003][1] := 9; CBP9[004][0] := 59; CBP9[004][1] := 9; CBP9[005][0] := 55; CBP9[005][1] := 9;
	CBP9[006][0] := 47; CBP9[006][1] := 9; CBP9[007][0] := 31; CBP9[007][1] := 9; CBP9[008][0] := 58; CBP9[008][1] := 8;
	CBP9[009][0] := 58; CBP9[009][1] := 8; CBP9[010][0] := 54; CBP9[010][1] := 8; CBP9[011][0] := 54; CBP9[011][1] := 8;
	CBP9[012][0] := 46; CBP9[012][1] := 8; CBP9[013][0] := 46; CBP9[013][1] := 8; CBP9[014][0] := 30; CBP9[014][1] := 8;
	CBP9[015][0] := 30; CBP9[015][1] := 8; CBP9[016][0] := 57; CBP9[016][1] := 8; CBP9[017][0] := 57; CBP9[017][1] := 8;
	CBP9[018][0] := 53; CBP9[018][1] := 8; CBP9[019][0] := 53; CBP9[019][1] := 8; CBP9[020][0] := 45; CBP9[020][1] := 8;
	CBP9[021][0] := 45; CBP9[021][1] := 8; CBP9[022][0] := 29; CBP9[022][1] := 8; CBP9[023][0] := 29; CBP9[023][1] := 8;
	CBP9[024][0] := 38; CBP9[024][1] := 8; CBP9[025][0] := 38; CBP9[025][1] := 8; CBP9[026][0] := 26; CBP9[026][1] := 8;
	CBP9[027][0] := 26; CBP9[027][1] := 8; CBP9[028][0] := 37; CBP9[028][1] := 8; CBP9[029][0] := 37; CBP9[029][1] := 8;
	CBP9[030][0] := 25; CBP9[030][1] := 8; CBP9[031][0] := 25; CBP9[031][1] := 8; CBP9[032][0] := 43; CBP9[032][1] := 8;
	CBP9[033][0] := 43; CBP9[033][1] := 8; CBP9[034][0] := 23; CBP9[034][1] := 8; CBP9[035][0] := 23; CBP9[035][1] := 8;
	CBP9[036][0] := 51; CBP9[036][1] := 8; CBP9[037][0] := 51; CBP9[037][1] := 8; CBP9[038][0] := 15; CBP9[038][1] := 8;
	CBP9[039][0] := 15; CBP9[039][1] := 8; CBP9[040][0] := 42; CBP9[040][1] := 8; CBP9[041][0] := 42; CBP9[041][1] := 8;
	CBP9[042][0] := 22; CBP9[042][1] := 8; CBP9[043][0] := 22; CBP9[043][1] := 8; CBP9[044][0] := 50; CBP9[044][1] := 8;
	CBP9[045][0] := 50; CBP9[045][1] := 8; CBP9[046][0] := 14; CBP9[046][1] := 8; CBP9[047][0] := 14; CBP9[047][1] := 8;
	CBP9[048][0] := 41; CBP9[048][1] := 8; CBP9[049][0] := 41; CBP9[049][1] := 8; CBP9[050][0] := 21; CBP9[050][1] := 8;
	CBP9[051][0] := 21; CBP9[051][1] := 8; CBP9[052][0] := 49; CBP9[052][1] := 8; CBP9[053][0] := 49; CBP9[053][1] := 8;
	CBP9[054][0] := 13; CBP9[054][1] := 8; CBP9[055][0] := 13; CBP9[055][1] := 8; CBP9[056][0] := 35; CBP9[056][1] := 8;
	CBP9[057][0] := 35; CBP9[057][1] := 8; CBP9[058][0] := 19; CBP9[058][1] := 8; CBP9[059][0] := 19; CBP9[059][1] := 8;
	CBP9[060][0] := 11; CBP9[060][1] := 8; CBP9[061][0] := 11; CBP9[061][1] := 8; CBP9[062][0] := 07; CBP9[062][1] := 8;
	CBP9[063][0] := 07; CBP9[063][1] := 8;

	(* first index: 4bit code read from stream; second index: 0->code, 1-> code length *)
	MC4[00][0] := 0; MC4[00][1] := 0; MC4[01][0] := 3; MC4[01][1] := 3; MC4[02][0] := 2; MC4[02][1] := 2; MC4[03][0] := 2; MC4[03][1] := 2;
	MC4[04][0] := 1; MC4[04][1] := 1; MC4[05][0] := 1; MC4[05][1] := 1; MC4[06][0] := 1; MC4[06][1] := 1; MC4[07][0] := 1; MC4[07][1] := 1;

	(* first index: 3bit code read from stream; second index: 0->code, 1-> code length *)
	MC7[00][0] := 0; MC7[00][1] := 0; MC7[01][0] := 0; MC7[01][1] := 0; MC7[02][0] := 0; MC7[02][1] := 0; MC7[03][0] := 7; MC7[03][1] := 3;
	MC7[04][0] := 6; MC7[04][1] := 3; MC7[05][0] := 5; MC7[05][1] := 3; MC7[06][0] := 4; MC7[06][1] := 2; MC7[07][0] := 4; MC7[07][1] := 2;

	(* first index: 5bit code read from stream (minus 12); second index: 0->code, 1-> code length *)
	MC10[00][0] := 16; MC10[00][1] := 5; MC10[01][0] := 15; MC10[01][1] := 5; MC10[02][0] := 14; MC10[02][1] := 5; MC10[03][0] := 13; MC10[03][1] := 5;
	MC10[04][0] := 12; MC10[04][1] := 5; MC10[05][0] := 11; MC10[05][1] := 5; MC10[06][0] := 10; MC10[06][1] := 4; MC10[07][0] := 10; MC10[07][1] := 4;
	MC10[08][0] := 09; MC10[08][1] := 4; MC10[09][0] := 09; MC10[09][1] := 4; MC10[10][0] := 08; MC10[10][1] := 4; MC10[11][0] := 08; MC10[11][1] := 4;

	(* first index: 3 bits read from stream; second index: 0->number of additional bits, 1->code length *)
	DCL3[0][0] := 1; DCL3[1][0] := 1; DCL3[2][0] := 2; DCL3[3][0] := 2; DCL3[4][0] := 0; DCL3[5][0] := 3; DCL3[6][0] := 4;
	DCL3[0][1] := 2; DCL3[1][1] := 2; DCL3[2][1] := 2; DCL3[3][1] := 2; DCL3[4][1] := 3; DCL3[5][1] := 3; DCL3[6][1] := 3;

	(* first index: 3 bits read from stream; second index: 0->number of additional bits, 1->code length *)
	DCC3[0][0] := 0; DCC3[1][0] := 0; DCC3[2][0] := 1; DCC3[3][0] := 1; DCC3[4][0] := 2; DCC3[5][0] := 2; DCC3[6][0] := 3;
	DCC3[0][1] := 2; DCC3[1][1] := 2; DCC3[2][1] := 2; DCC3[3][1] := 2; DCC3[4][1] := 2; DCC3[5][1] := 2; DCC3[6][1] := 3;

	RLC6[00][0] := 0; RLC6[00][1] := 3; RLC6[00][2] := 5; RLC6[01][0] := 4; RLC6[01][1] := 1; RLC6[01][2] := 5;
	RLC6[02][0] := 3; RLC6[02][1] := 1; RLC6[02][2] := 5; RLC6[03][0] := 0; RLC6[03][1] := 2; RLC6[03][2] := 4;
	RLC6[04][0] := 0; RLC6[04][1] := 2; RLC6[04][2] := 4; RLC6[05][0] := 2; RLC6[05][1] := 1; RLC6[05][2] := 4;
	RLC6[06][0] := 2; RLC6[06][1] := 1; RLC6[06][2] := 4; RLC6[07][0] := 1; RLC6[07][1] := 1; RLC6[07][2] := 3;
	RLC6[08][0] := 1; RLC6[08][1] := 1; RLC6[08][2] := 3; RLC6[09][0] := 1; RLC6[09][1] := 1; RLC6[09][2] := 3;
	RLC6[10][0] := 1; RLC6[10][1] := 1; RLC6[10][2] := 3;

	RLC8[00][0] := 2; RLC8[00][1] := 2; RLC8[00][2] := 7; RLC8[01][0] := 9; RLC8[01][1] := 1; RLC8[01][2] := 7;
	RLC8[02][0] := 0; RLC8[02][1] := 4; RLC8[02][2] := 7; RLC8[03][0] := 8; RLC8[03][1] := 1; RLC8[03][2] := 7;
	RLC8[04][0] := 7; RLC8[04][1] := 1; RLC8[04][2] := 6; RLC8[05][0] := 7; RLC8[05][1] := 1; RLC8[05][2] := 6;
	RLC8[06][0] := 6; RLC8[06][1] := 1; RLC8[06][2] := 6; RLC8[07][0] := 6; RLC8[07][1] := 1; RLC8[07][2] := 6;
	RLC8[08][0] := 1; RLC8[08][1] := 2; RLC8[08][2] := 6; RLC8[09][0] := 1; RLC8[09][1] := 2; RLC8[09][2] := 6;
	RLC8[10][0] := 5; RLC8[10][1] := 1; RLC8[10][2] := 6; RLC8[11][0] := 5; RLC8[11][1] := 1; RLC8[11][2] := 6;

	RLC8_2[00][0] := 7; RLC8_2[00][1] := 1; RLC8_2[00][2] := 7; RLC8_2[01][0] := 8; RLC8_2[01][1] := 1; RLC8_2[01][2] := 7;
	RLC8_2[02][0] := 6; RLC8_2[02][1] := 1; RLC8_2[02][2] := 7; RLC8_2[03][0] := 2; RLC8_2[03][1] := 2; RLC8_2[03][2] := 7;
	RLC8_2[04][0] := 0; RLC8_2[04][1] := 7; RLC8_2[04][2] := 6; RLC8_2[05][0] := 0; RLC8_2[05][1] := 7; RLC8_2[05][2] := 6;
	RLC8_2[06][0] := 0; RLC8_2[06][1] := 6; RLC8_2[06][2] := 6; RLC8_2[07][0] := 0; RLC8_2[07][1] := 6; RLC8_2[07][2] := 6;
	RLC8_2[08][0] := 4; RLC8_2[08][1] := 1; RLC8_2[08][2] := 6; RLC8_2[09][0] := 4; RLC8_2[09][1] := 1; RLC8_2[09][2] := 6;
	RLC8_2[10][0] := 5; RLC8_2[10][1] := 1; RLC8_2[10][2] := 6; RLC8_2[11][0] := 5; RLC8_2[11][1] := 1; RLC8_2[11][2] := 6;

	RLC9[00][0] := 13; RLC9[00][1] := 1; RLC9[01][0] := 00; RLC9[01][1] := 6; RLC9[02][0] := 12; RLC9[02][1] := 1;
	RLC9[03][0] := 11; RLC9[03][1] := 1; RLC9[04][0] := 03; RLC9[04][1] := 2; RLC9[05][0] := 01; RLC9[05][1] := 3;
	RLC9[06][0] := 00; RLC9[06][1] := 5; RLC9[07][0] := 10; RLC9[07][1] := 1;

	RLC9_2[00][0] := 01; RLC9_2[00][1] := 05; RLC9_2[01][0] := 11; RLC9_2[01][1] := 01; RLC9_2[02][0] := 00; RLC9_2[02][1] := 11;
	RLC9_2[03][0] := 00; RLC9_2[03][1] := 10; RLC9_2[04][0] := 13; RLC9_2[04][1] := 01; RLC9_2[05][0] := 12; RLC9_2[05][1] := 01;
	RLC9_2[06][0] := 03; RLC9_2[06][1] := 02; RLC9_2[07][0] := 01; RLC9_2[07][1] := 04;

	RLC9_2_2[00][0] := 09; RLC9_2_2[00][1] := 01; RLC9_2_2[00][2] := 7; RLC9_2_2[01][0] := 09; RLC9_2_2[01][1] := 01; RLC9_2_2[01][2] := 7;
	RLC9_2_2[02][0] := 01; RLC9_2_2[02][1] := 03; RLC9_2_2[02][2] := 7; RLC9_2_2[03][0] := 01; RLC9_2_2[03][1] := 03; RLC9_2_2[03][2] := 7;
	RLC9_2_2[04][0] := 10; RLC9_2_2[04][1] := 01; RLC9_2_2[04][2] := 7; RLC9_2_2[05][0] := 10; RLC9_2_2[05][1] := 01; RLC9_2_2[05][2] := 7;
	RLC9_2_2[06][0] := 00; RLC9_2_2[06][1] := 06; RLC9_2_2[06][2] := 7; RLC9_2_2[07][0] := 00; RLC9_2_2[07][1] := 06; RLC9_2_2[07][2] := 7;
	RLC9_2_2[08][0] := 00; RLC9_2_2[08][1] := 09; RLC9_2_2[08][2] := 7; RLC9_2_2[09][0] := 00; RLC9_2_2[09][1] := 09; RLC9_2_2[09][2] := 7;
	RLC9_2_2[10][0] := 00; RLC9_2_2[10][1] := 12; RLC9_2_2[10][2] := 8; RLC9_2_2[11][0] := 00; RLC9_2_2[11][1] := 13; RLC9_2_2[11][2] := 8;
	RLC9_2_2[12][0] := 02; RLC9_2_2[12][1] := 03; RLC9_2_2[12][2] := 8; RLC9_2_2[13][0] := 04; RLC9_2_2[13][1] := 02; RLC9_2_2[13][2] := 8;
	RLC9_2_2[14][0] := 00; RLC9_2_2[14][1] := 14; RLC9_2_2[14][2] := 8; RLC9_2_2[15][0] := 00; RLC9_2_2[15][1] := 16; RLC9_2_2[15][2] := 8;

	RLC11[00][0] := 16; RLC11[00][1] := 1; RLC11[01][0] := 5; RLC11[01][1] := 2; RLC11[02][0] := 0; RLC11[02][1] := 7;
	RLC11[03][0] := 2; RLC11[03][1] := 3; RLC11[04][0] := 1; RLC11[04][1] := 4; RLC11[05][0] := 15; RLC11[05][1] := 1;
	RLC11[06][0] := 14; RLC11[06][1] := 1; RLC11[07][0] := 4; RLC11[07][1] := 2;

	RLC13[00][0] := 0; RLC13[00][1] := 11; RLC13[01][0] := 8; RLC13[01][1] := 2; RLC13[02][0] := 4; RLC13[02][1] := 3;
	RLC13[03][0] := 0; RLC13[03][1] := 10; RLC13[04][0] := 2; RLC13[04][1] := 4; RLC13[05][0] := 7; RLC13[05][1] := 2;
	RLC13[06][0] := 21; RLC13[06][1] := 1; RLC13[07][0] := 20; RLC13[07][1] := 1; RLC13[08][0] := 0; RLC13[08][1] := 9;
	RLC13[09][0] := 19; RLC13[09][1] := 1; RLC13[10][0] := 18; RLC13[10][1] := 1; RLC13[11][0] := 1; RLC13[11][1] := 5;
	RLC13[12][0] := 3; RLC13[12][1] := 3; RLC13[13][0] := 0; RLC13[13][1] := 8; RLC13[14][0] := 6; RLC13[14][1] := 2;
	RLC13[15][0] := 17; RLC13[15][1] := 1;

	RLC14[00][0] := 10; RLC14[00][1] := 2; RLC14[01][0] := 9; RLC14[01][1] := 2; RLC14[02][0] := 5; RLC14[02][1] := 3;
	RLC14[03][0] := 3; RLC14[03][1] := 4; RLC14[04][0] := 2; RLC14[04][1] := 5; RLC14[05][0] := 1; RLC14[05][1] := 7;
	RLC14[06][0] := 1; RLC14[06][1] := 6; RLC14[07][0] := 0; RLC14[07][1] := 15; RLC14[08][0] := 0; RLC14[08][1] := 14;
	RLC14[09][0] := 0; RLC14[09][1] := 13; RLC14[10][0] := 0; RLC14[10][1] := 12; RLC14[11][0] := 26; RLC14[11][1] := 1;
	RLC14[12][0] := 25; RLC14[12][1] := 1; RLC14[13][0] := 24; RLC14[13][1] := 1; RLC14[14][0] := 23; RLC14[14][1] := 1;
	RLC14[15][0] := 22; RLC14[15][1] := 1;

	RLC16[00][0] := 0; RLC16[00][1] := 40; RLC16[01][0] := 0; RLC16[01][1] := 39; RLC16[02][0] := 0; RLC16[02][1] := 38;
	RLC16[03][0] := 0; RLC16[03][1] := 37; RLC16[04][0] := 0; RLC16[04][1] := 36; RLC16[05][0] := 0; RLC16[05][1] := 35;
	RLC16[06][0] := 0; RLC16[06][1] := 34; RLC16[07][0] := 0; RLC16[07][1] := 33; RLC16[08][0] := 0; RLC16[08][1] := 32;
	RLC16[09][0] := 1; RLC16[09][1] := 14; RLC16[10][0] := 1; RLC16[10][1] := 13; RLC16[11][0] := 1; RLC16[11][1] := 12;
	RLC16[12][0] := 1; RLC16[12][1] := 11; RLC16[13][0] := 1; RLC16[13][1] := 10; RLC16[14][0] := 1; RLC16[14][1] := 9;
	RLC16[15][0] := 1; RLC16[15][1] := 8;

	RLC17[00][0] := 1; RLC17[00][1] := 18; RLC17[01][0] := 1; RLC17[01][1] := 17; RLC17[02][0] := 1; RLC17[02][1] := 16;
	RLC17[03][0] := 1; RLC17[03][1] := 15; RLC17[04][0] := 6; RLC17[04][1] := 3; RLC17[05][0] := 16; RLC17[05][1] := 2;
	RLC17[06][0] := 15; RLC17[06][1] := 2; RLC17[07][0] := 14; RLC17[07][1] := 2; RLC17[08][0] := 13; RLC17[08][1] := 2;
	RLC17[09][0] := 12; RLC17[09][1] := 2; RLC17[10][0] := 11; RLC17[10][1] := 2; RLC17[11][0] := 31; RLC17[11][1] := 1;
	RLC17[12][0] := 30; RLC17[12][1] := 1; RLC17[13][0] := 29; RLC17[13][1] := 1; RLC17[14][0] := 28; RLC17[14][1] := 1;
	RLC17[15][0] := 27; RLC17[15][1] := 1;

	QS0[00] := -1; QS0[01] := 02; QS0[02] := 04; QS0[03] := 06; QS0[04] := 08;
	QS0[05] := 10; QS0[06] := 12; QS0[07] := 14; QS0[08] := 16; QS0[09] := 18;
	QS0[10] := 20; QS0[11] := 22; QS0[12] := 24; QS0[13] := 26; QS0[14] := 28;
	QS0[15] := 30; QS0[16] := 32; QS0[17] := 34; QS0[18] := 36; QS0[19] := 38;
	QS0[20] := 40; QS0[21] := 42; QS0[22] := 44; QS0[23] := 46; QS0[24] := 48;
	QS0[25] := 50; QS0[26] := 52; QS0[27] := 54; QS0[28] := 56; QS0[29] := 58;
	QS0[30] := 60; QS0[31] := 62;

	QS1[00] := -1; QS1[01] := 01; QS1[02] := 02; QS1[03] := 03; QS1[04] := 04;
	QS1[05] := 05; QS1[06] := 06; QS1[07] := 07; QS1[08] := 08; QS1[09] := 10;
	QS1[10] := 12; QS1[11] := 14; QS1[12] := 16; QS1[13] := 18; QS1[14] := 20;
	QS1[15] := 22; QS1[16] := 24; QS1[17] := 28; QS1[18] := 32; QS1[19] := 36;
	QS1[20] := 40; QS1[21] := 44; QS1[22] := 48; QS1[23] := 52; QS1[24] := 56;
	QS1[25] := 64; QS1[26] := 72; QS1[27] := 80; QS1[28] := 88; QS1[29] := 96;
	QS1[30] := 104; QS1[31] := 112;

	DCP[0] := 128; DCP[1] := 256; DCP[2] := 512; DCP[3] := 1024;

	DCM[0] := 8; DCM[1] := 4; DCM[2] := 2; DCM[3] := 1;

	FBB[0] := 0; FBB[1] := 2; FBB[2] := 4; FBB[3] := 6; FBB[4] := 1; FBB[5] := 3; FBB[6] := 5; FBB[7] := 7;

END MPEGTables.