diff options
Diffstat (limited to 'appl/wm/mpeg')
57 files changed, 12061 insertions, 0 deletions
diff --git a/appl/wm/mpeg/c0.tab b/appl/wm/mpeg/c0.tab new file mode 100644 index 00000000..3949d009 --- /dev/null +++ b/appl/wm/mpeg/c0.tab @@ -0,0 +1,261 @@ +# vlc -uUNDEF,UNDEF c0 +c0_size: con 256; +c0_bits: con 8; +c0_table:= array[] of { + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (0, UNDEF,UNDEF), + (8, 18,1), + (8, -18,1), + (8, 17,1), + (8, -17,1), + (8, 16,1), + (8, -16,1), + (8, 15,1), + (8, -15,1), + (8, 3,6), + (8, -3,6), + (8, 2,16), + (8, -2,16), + (8, 2,15), + (8, -2,15), + (8, 2,14), + (8, -2,14), + (8, 2,13), + (8, -2,13), + (8, 2,12), + (8, -2,12), + (8, 2,11), + (8, -2,11), + (8, 1,31), + (8, -1,31), + (8, 1,30), + (8, -1,30), + (8, 1,29), + (8, -1,29), + (8, 1,28), + (8, -1,28), + (8, 1,27), + (8, -1,27), + (7, 40,0), + (7, 40,0), + (7, -40,0), + (7, -40,0), + (7, 39,0), + (7, 39,0), + (7, -39,0), + (7, -39,0), + (7, 38,0), + (7, 38,0), + (7, -38,0), + (7, -38,0), + (7, 37,0), + (7, 37,0), + (7, -37,0), + (7, -37,0), + (7, 36,0), + (7, 36,0), + (7, -36,0), + (7, -36,0), + (7, 35,0), + (7, 35,0), + (7, -35,0), + (7, -35,0), + (7, 34,0), + (7, 34,0), + (7, -34,0), + (7, -34,0), + (7, 33,0), + (7, 33,0), + (7, -33,0), + (7, -33,0), + (7, 32,0), + (7, 32,0), + (7, -32,0), + (7, -32,0), + (7, 14,1), + (7, 14,1), + (7, -14,1), + (7, -14,1), + (7, 13,1), + (7, 13,1), + (7, -13,1), + (7, -13,1), + (7, 12,1), + (7, 12,1), + (7, -12,1), + (7, -12,1), + (7, 11,1), + (7, 11,1), + (7, -11,1), + (7, -11,1), + (7, 10,1), + (7, 10,1), + (7, -10,1), + (7, -10,1), + (7, 9,1), + (7, 9,1), + (7, -9,1), + (7, -9,1), + (7, 8,1), + (7, 8,1), + (7, -8,1), + (7, -8,1), + (6, 31,0), + (6, 31,0), + (6, 31,0), + (6, 31,0), + (6, -31,0), + (6, -31,0), + (6, -31,0), + (6, -31,0), + (6, 30,0), + (6, 30,0), + (6, 30,0), + (6, 30,0), + (6, -30,0), + (6, -30,0), + (6, -30,0), + (6, -30,0), + (6, 29,0), + (6, 29,0), + (6, 29,0), + (6, 29,0), + (6, -29,0), + (6, -29,0), + (6, -29,0), + (6, -29,0), + (6, 28,0), + (6, 28,0), + (6, 28,0), + (6, 28,0), + (6, -28,0), + (6, -28,0), + (6, -28,0), + (6, -28,0), + (6, 27,0), + (6, 27,0), + (6, 27,0), + (6, 27,0), + (6, -27,0), + (6, -27,0), + (6, -27,0), + (6, -27,0), + (6, 26,0), + (6, 26,0), + (6, 26,0), + (6, 26,0), + (6, -26,0), + (6, -26,0), + (6, -26,0), + (6, -26,0), + (6, 25,0), + (6, 25,0), + (6, 25,0), + (6, 25,0), + (6, -25,0), + (6, -25,0), + (6, -25,0), + (6, -25,0), + (6, 24,0), + (6, 24,0), + (6, 24,0), + (6, 24,0), + (6, -24,0), + (6, -24,0), + (6, -24,0), + (6, -24,0), + (6, 23,0), + (6, 23,0), + (6, 23,0), + (6, 23,0), + (6, -23,0), + (6, -23,0), + (6, -23,0), + (6, -23,0), + (6, 22,0), + (6, 22,0), + (6, 22,0), + (6, 22,0), + (6, -22,0), + (6, -22,0), + (6, -22,0), + (6, -22,0), + (6, 21,0), + (6, 21,0), + (6, 21,0), + (6, 21,0), + (6, -21,0), + (6, -21,0), + (6, -21,0), + (6, -21,0), + (6, 20,0), + (6, 20,0), + (6, 20,0), + (6, 20,0), + (6, -20,0), + (6, -20,0), + (6, -20,0), + (6, -20,0), + (6, 19,0), + (6, 19,0), + (6, 19,0), + (6, 19,0), + (6, -19,0), + (6, -19,0), + (6, -19,0), + (6, -19,0), + (6, 18,0), + (6, 18,0), + (6, 18,0), + (6, 18,0), + (6, -18,0), + (6, -18,0), + (6, -18,0), + (6, -18,0), + (6, 17,0), + (6, 17,0), + (6, 17,0), + (6, 17,0), + (6, -17,0), + (6, -17,0), + (6, -17,0), + (6, -17,0), + (6, 16,0), + (6, 16,0), + (6, 16,0), + (6, 16,0), + (6, -16,0), + (6, -16,0), + (6, -16,0), + (6, -16,0), +}; diff --git a/appl/wm/mpeg/c0.vlc b/appl/wm/mpeg/c0.vlc new file mode 100644 index 00000000..cc1af6e6 --- /dev/null +++ b/appl/wm/mpeg/c0.vlc @@ -0,0 +1,50 @@ +# Run/Level continuation 0 +# vlc -uUNDEF,UNDEF c0 < c0.vlc > c0.tab +11111s 16,0 +11110s 17,0 +11101s 18,0 +11100s 19,0 +11011s 20,0 +11010s 21,0 +11001s 22,0 +11000s 23,0 +10111s 24,0 +10110s 25,0 +10101s 26,0 +10100s 27,0 +10011s 28,0 +10010s 29,0 +10001s 30,0 +10000s 31,0 +011000s 32,0 +010111s 33,0 +010110s 34,0 +010101s 35,0 +010100s 36,0 +010011s 37,0 +010010s 38,0 +010001s 39,0 +010000s 40,0 +011111s 8,1 +011110s 9,1 +011101s 10,1 +011100s 11,1 +011011s 12,1 +011010s 13,1 +011001s 14,1 +0010011s 15,1 +0010010s 16,1 +0010001s 17,1 +0010000s 18,1 +0010100s 3,6 +0011010s 2,11 +0011001s 2,12 +0011000s 2,13 +0010111s 2,14 +0010110s 2,15 +0010101s 2,16 +0011111s 1,27 +0011110s 1,28 +0011101s 1,29 +0011100s 1,30 +0011011s 1,31 diff --git a/appl/wm/mpeg/c1.tab b/appl/wm/mpeg/c1.tab new file mode 100644 index 00000000..ff834508 --- /dev/null +++ b/appl/wm/mpeg/c1.tab @@ -0,0 +1,37 @@ +# vlc -cfp c1 +c1_size: con 32; +c1_bits: con 5; +c1_table:= array[] of { + (2,10), + (-2,10), + (2,9), + (-2,9), + (3,5), + (-3,5), + (4,3), + (-4,3), + (5,2), + (-5,2), + (7,1), + (-7,1), + (6,1), + (-6,1), + (15,0), + (-15,0), + (14,0), + (-14,0), + (13,0), + (-13,0), + (12,0), + (-12,0), + (1,26), + (-1,26), + (1,25), + (-1,25), + (1,24), + (-1,24), + (1,23), + (-1,23), + (1,22), + (-1,22), +}; diff --git a/appl/wm/mpeg/c1.vlc b/appl/wm/mpeg/c1.vlc new file mode 100644 index 00000000..1e18d599 --- /dev/null +++ b/appl/wm/mpeg/c1.vlc @@ -0,0 +1,18 @@ +# Run/Level continuation 1 +# vlc -cfp c1 < c1.vlc > c1.tab +1010s 12,0 +1001s 13,0 +1000s 14,0 +0111s 15,0 +0110s 6,1 +0101s 7,1 +0100s 5,2 +0011s 4,3 +0010s 3,5 +0001s 2,9 +0000s 2,10 +1111s 1,22 +1110s 1,23 +1101s 1,24 +1100s 1,25 +1011s 1,26 diff --git a/appl/wm/mpeg/c2.tab b/appl/wm/mpeg/c2.tab new file mode 100644 index 00000000..69c0ebf2 --- /dev/null +++ b/appl/wm/mpeg/c2.tab @@ -0,0 +1,21 @@ +# vlc -cfp c2 +c2_size: con 16; +c2_bits: con 4; +c2_table:= array[] of { + (11,0), + (-11,0), + (2,8), + (-2,8), + (3,4), + (-3,4), + (10,0), + (-10,0), + (4,2), + (-4,2), + (2,7), + (-2,7), + (1,21), + (-1,21), + (1,20), + (-1,20), +}; diff --git a/appl/wm/mpeg/c2.vlc b/appl/wm/mpeg/c2.vlc new file mode 100644 index 00000000..167d011a --- /dev/null +++ b/appl/wm/mpeg/c2.vlc @@ -0,0 +1,10 @@ +# Run/Level continuation 2 +# vlc -cfp c2 < c2.vlc > c2.tab +011s 10,0 +000s 11,0 +100s 4,2 +010s 3,4 +101s 2,7 +001s 2,8 +111s 1,20 +110s 1,21 diff --git a/appl/wm/mpeg/c3.tab b/appl/wm/mpeg/c3.tab new file mode 100644 index 00000000..06fd7cfb --- /dev/null +++ b/appl/wm/mpeg/c3.tab @@ -0,0 +1,21 @@ +# vlc -cfp c3 +c3_size: con 16; +c3_bits: con 4; +c3_table:= array[] of { + (9,0), + (-9,0), + (1,19), + (-1,19), + (1,18), + (-1,18), + (5,1), + (-5,1), + (3,3), + (-3,3), + (8,0), + (-8,0), + (2,6), + (-2,6), + (1,17), + (-1,17), +}; diff --git a/appl/wm/mpeg/c3.vlc b/appl/wm/mpeg/c3.vlc new file mode 100644 index 00000000..df6a8c46 --- /dev/null +++ b/appl/wm/mpeg/c3.vlc @@ -0,0 +1,10 @@ +# Run/Level continuation 3 +# vlc -cfp c3 < c3.vlc > c3.tab +101s 8,0 +000s 9,0 +011s 5,1 +100s 3,3 +110s 2,6 +111s 1,17 +010s 1,18 +001s 1,19 diff --git a/appl/wm/mpeg/c4.tab b/appl/wm/mpeg/c4.tab new file mode 100644 index 00000000..db1c3a56 --- /dev/null +++ b/appl/wm/mpeg/c4.tab @@ -0,0 +1,9 @@ +# vlc -cfp c4 +c4_size: con 4; +c4_bits: con 2; +c4_table:= array[] of { + (1,16), + (-1,16), + (2,5), + (-2,5), +}; diff --git a/appl/wm/mpeg/c4.vlc b/appl/wm/mpeg/c4.vlc new file mode 100644 index 00000000..cd6797d1 --- /dev/null +++ b/appl/wm/mpeg/c4.vlc @@ -0,0 +1,4 @@ +# Run/Level continuation 4 +# vlc -cfp c4 < c4.vlc > c4.tab +0s 1,16 +1s 2,5 diff --git a/appl/wm/mpeg/c5.tab b/appl/wm/mpeg/c5.tab new file mode 100644 index 00000000..98a1d285 --- /dev/null +++ b/appl/wm/mpeg/c5.tab @@ -0,0 +1,9 @@ +# vlc -cfp c5 +c5_size: con 4; +c5_bits: con 2; +c5_table:= array[] of { + (7,0), + (-7,0), + (3,2), + (-3,2), +}; diff --git a/appl/wm/mpeg/c5.vlc b/appl/wm/mpeg/c5.vlc new file mode 100644 index 00000000..ae0c10a8 --- /dev/null +++ b/appl/wm/mpeg/c5.vlc @@ -0,0 +1,4 @@ +# Run/Level continuation 5 +# vlc -cfp c5 < c5.vlc > c5.tab +0s 7,0 +1s 3,2 diff --git a/appl/wm/mpeg/c6.tab b/appl/wm/mpeg/c6.tab new file mode 100644 index 00000000..fe1c5c35 --- /dev/null +++ b/appl/wm/mpeg/c6.tab @@ -0,0 +1,9 @@ +# vlc -cfp c6 +c6_size: con 4; +c6_bits: con 2; +c6_table:= array[] of { + (4,1), + (-4,1), + (1,15), + (-1,15), +}; diff --git a/appl/wm/mpeg/c6.vlc b/appl/wm/mpeg/c6.vlc new file mode 100644 index 00000000..86165acf --- /dev/null +++ b/appl/wm/mpeg/c6.vlc @@ -0,0 +1,4 @@ +# Run/Level continuation 6 +# vlc -cfp c6 < c6.vlc > c6.tab +0s 4,1 +1s 1,15 diff --git a/appl/wm/mpeg/c7.tab b/appl/wm/mpeg/c7.tab new file mode 100644 index 00000000..a0385192 --- /dev/null +++ b/appl/wm/mpeg/c7.tab @@ -0,0 +1,9 @@ +# vlc -cfp c7 +c7_size: con 4; +c7_bits: con 2; +c7_table:= array[] of { + (1,14), + (-1,14), + (2,4), + (-2,4), +}; diff --git a/appl/wm/mpeg/c7.vlc b/appl/wm/mpeg/c7.vlc new file mode 100644 index 00000000..45986054 --- /dev/null +++ b/appl/wm/mpeg/c7.vlc @@ -0,0 +1,4 @@ +# Run/Level continuation 7 +# vlc -cfp c7 < c7.vlc > c7.tab +0s 1,14 +1s 2,4 diff --git a/appl/wm/mpeg/cbp.tab b/appl/wm/mpeg/cbp.tab new file mode 100644 index 00000000..ee97febb --- /dev/null +++ b/appl/wm/mpeg/cbp.tab @@ -0,0 +1,517 @@ +# vlc cbp +cbp_size: con 512; +cbp_bits: con 9; +cbp_table:= array[] of { + (0, UNDEF), + (0, UNDEF), + (9, 39), + (9, 27), + (9, 59), + (9, 55), + (9, 47), + (9, 31), + (8, 58), + (8, 58), + (8, 54), + (8, 54), + (8, 46), + (8, 46), + (8, 30), + (8, 30), + (8, 57), + (8, 57), + (8, 53), + (8, 53), + (8, 45), + (8, 45), + (8, 29), + (8, 29), + (8, 38), + (8, 38), + (8, 26), + (8, 26), + (8, 37), + (8, 37), + (8, 25), + (8, 25), + (8, 43), + (8, 43), + (8, 23), + (8, 23), + (8, 51), + (8, 51), + (8, 15), + (8, 15), + (8, 42), + (8, 42), + (8, 22), + (8, 22), + (8, 50), + (8, 50), + (8, 14), + (8, 14), + (8, 41), + (8, 41), + (8, 21), + (8, 21), + (8, 49), + (8, 49), + (8, 13), + (8, 13), + (8, 35), + (8, 35), + (8, 19), + (8, 19), + (8, 11), + (8, 11), + (8, 7), + (8, 7), + (7, 34), + (7, 34), + (7, 34), + (7, 34), + (7, 18), + (7, 18), + (7, 18), + (7, 18), + (7, 10), + (7, 10), + (7, 10), + (7, 10), + (7, 6), + (7, 6), + (7, 6), + (7, 6), + (7, 33), + (7, 33), + (7, 33), + (7, 33), + (7, 17), + (7, 17), + (7, 17), + (7, 17), + (7, 9), + (7, 9), + (7, 9), + (7, 9), + (7, 5), + (7, 5), + (7, 5), + (7, 5), + (6, 63), + (6, 63), + (6, 63), + (6, 63), + (6, 63), + (6, 63), + (6, 63), + (6, 63), + (6, 3), + (6, 3), + (6, 3), + (6, 3), + (6, 3), + (6, 3), + (6, 3), + (6, 3), + (6, 36), + (6, 36), + (6, 36), + (6, 36), + (6, 36), + (6, 36), + (6, 36), + (6, 36), + (6, 24), + (6, 24), + (6, 24), + (6, 24), + (6, 24), + (6, 24), + (6, 24), + (6, 24), + (5, 62), + (5, 62), + (5, 62), + (5, 62), + (5, 62), + (5, 62), + (5, 62), + (5, 62), + (5, 62), + (5, 62), + (5, 62), + (5, 62), + (5, 62), + (5, 62), + (5, 62), + (5, 62), + (5, 2), + (5, 2), + (5, 2), + (5, 2), + (5, 2), + (5, 2), + (5, 2), + (5, 2), + (5, 2), + (5, 2), + (5, 2), + (5, 2), + (5, 2), + (5, 2), + (5, 2), + (5, 2), + (5, 61), + (5, 61), + (5, 61), + (5, 61), + (5, 61), + (5, 61), + (5, 61), + (5, 61), + (5, 61), + (5, 61), + (5, 61), + (5, 61), + (5, 61), + (5, 61), + (5, 61), + (5, 61), + (5, 1), + (5, 1), + (5, 1), + (5, 1), + (5, 1), + (5, 1), + (5, 1), + (5, 1), + (5, 1), + (5, 1), + (5, 1), + (5, 1), + (5, 1), + (5, 1), + (5, 1), + (5, 1), + (5, 56), + (5, 56), + (5, 56), + (5, 56), + (5, 56), + (5, 56), + (5, 56), + (5, 56), + (5, 56), + (5, 56), + (5, 56), + (5, 56), + (5, 56), + (5, 56), + (5, 56), + (5, 56), + (5, 52), + (5, 52), + (5, 52), + (5, 52), + (5, 52), + (5, 52), + (5, 52), + (5, 52), + (5, 52), + (5, 52), + (5, 52), + (5, 52), + (5, 52), + (5, 52), + (5, 52), + (5, 52), + (5, 44), + (5, 44), + (5, 44), + (5, 44), + (5, 44), + (5, 44), + (5, 44), + (5, 44), + (5, 44), + (5, 44), + (5, 44), + (5, 44), + (5, 44), + (5, 44), + (5, 44), + (5, 44), + (5, 28), + (5, 28), + (5, 28), + (5, 28), + (5, 28), + (5, 28), + (5, 28), + (5, 28), + (5, 28), + (5, 28), + (5, 28), + (5, 28), + (5, 28), + (5, 28), + (5, 28), + (5, 28), + (5, 40), + (5, 40), + (5, 40), + (5, 40), + (5, 40), + (5, 40), + (5, 40), + (5, 40), + (5, 40), + (5, 40), + (5, 40), + (5, 40), + (5, 40), + (5, 40), + (5, 40), + (5, 40), + (5, 20), + (5, 20), + (5, 20), + (5, 20), + (5, 20), + (5, 20), + (5, 20), + (5, 20), + (5, 20), + (5, 20), + (5, 20), + (5, 20), + (5, 20), + (5, 20), + (5, 20), + (5, 20), + (5, 48), + (5, 48), + (5, 48), + (5, 48), + (5, 48), + (5, 48), + (5, 48), + (5, 48), + (5, 48), + (5, 48), + (5, 48), + (5, 48), + (5, 48), + (5, 48), + (5, 48), + (5, 48), + (5, 12), + (5, 12), + (5, 12), + (5, 12), + (5, 12), + (5, 12), + (5, 12), + (5, 12), + (5, 12), + (5, 12), + (5, 12), + (5, 12), + (5, 12), + (5, 12), + (5, 12), + (5, 12), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 32), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 16), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 8), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), + (3, 60), +}; diff --git a/appl/wm/mpeg/cbp.vlc b/appl/wm/mpeg/cbp.vlc new file mode 100644 index 00000000..c7c9438c --- /dev/null +++ b/appl/wm/mpeg/cbp.vlc @@ -0,0 +1,65 @@ +# Coded Block Pattern +# vlc cbp < cbp.vlc > cbp.tab +01011 1 +01001 2 +001101 3 +1101 4 +0010111 5 +0010011 6 +00011111 7 +1100 8 +0010110 9 +0010010 10 +00011110 11 +10011 12 +00011011 13 +00010111 14 +00010011 15 +1011 16 +0010101 17 +0010001 18 +00011101 19 +10001 20 +00011001 21 +00010101 22 +00010001 23 +001111 24 +00001111 25 +00001101 26 +000000011 27 +01111 28 +00001011 29 +00000111 30 +000000111 31 +1010 32 +0010100 33 +0010000 34 +00011100 35 +001110 36 +00001110 37 +00001100 38 +000000010 39 +10000 40 +00011000 41 +00010100 42 +00010000 43 +01110 44 +00001010 45 +00000110 46 +000000110 47 +10010 48 +00011010 49 +00010110 50 +00010010 51 +01101 52 +00001001 53 +00000101 54 +000000101 55 +01100 56 +00001000 57 +00000100 58 +000000100 59 +111 60 +01010 61 +01000 62 +001100 63 diff --git a/appl/wm/mpeg/cdc.tab b/appl/wm/mpeg/cdc.tab new file mode 100644 index 00000000..91ccb057 --- /dev/null +++ b/appl/wm/mpeg/cdc.tab @@ -0,0 +1,261 @@ +# vlc cdc +cdc_size: con 256; +cdc_bits: con 8; +cdc_table:= array[] of { + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 0), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (5, 5), + (5, 5), + (5, 5), + (5, 5), + (5, 5), + (5, 5), + (5, 5), + (5, 5), + (6, 6), + (6, 6), + (6, 6), + (6, 6), + (7, 7), + (7, 7), + (8, 8), + (0, UNDEF), +}; diff --git a/appl/wm/mpeg/cdc.vlc b/appl/wm/mpeg/cdc.vlc new file mode 100644 index 00000000..fadf199f --- /dev/null +++ b/appl/wm/mpeg/cdc.vlc @@ -0,0 +1,11 @@ +# Chrominance DC +# vlc cdc < cdc.vlc > cdc.tab +00 0 +01 1 +10 2 +110 3 +1110 4 +11110 5 +111110 6 +1111110 7 +11111110 8 diff --git a/appl/wm/mpeg/closest.m b/appl/wm/mpeg/closest.m new file mode 100644 index 00000000..eccd7dab --- /dev/null +++ b/appl/wm/mpeg/closest.m @@ -0,0 +1,514 @@ +closest := array[16*16*16] of { + byte 255,byte 255,byte 255,byte 254,byte 254,byte 237,byte 220,byte 203, + byte 253,byte 236,byte 219,byte 202,byte 252,byte 235,byte 218,byte 201, + byte 255,byte 255,byte 255,byte 254,byte 254,byte 237,byte 220,byte 203, + byte 253,byte 236,byte 219,byte 202,byte 252,byte 235,byte 218,byte 201, + byte 255,byte 255,byte 255,byte 250,byte 250,byte 250,byte 220,byte 249, + byte 249,byte 249,byte 232,byte 248,byte 248,byte 248,byte 231,byte 201, + byte 251,byte 251,byte 250,byte 250,byte 250,byte 250,byte 249,byte 249, + byte 249,byte 249,byte 232,byte 248,byte 248,byte 248,byte 231,byte 201, + byte 251,byte 251,byte 250,byte 250,byte 250,byte 233,byte 233,byte 249, + byte 249,byte 232,byte 215,byte 215,byte 248,byte 231,byte 214,byte 197, + byte 234,byte 234,byte 250,byte 250,byte 233,byte 233,byte 216,byte 216, + byte 249,byte 232,byte 215,byte 198,byte 198,byte 231,byte 214,byte 197, + byte 217,byte 217,byte 217,byte 246,byte 233,byte 216,byte 216,byte 199, + byte 199,byte 215,byte 215,byte 198,byte 198,byte 198,byte 214,byte 197, + byte 200,byte 200,byte 246,byte 246,byte 246,byte 216,byte 199,byte 199, + byte 245,byte 245,byte 198,byte 244,byte 244,byte 244,byte 227,byte 197, + byte 247,byte 247,byte 246,byte 246,byte 246,byte 246,byte 199,byte 245, + byte 245,byte 245,byte 228,byte 244,byte 244,byte 244,byte 227,byte 193, + byte 230,byte 230,byte 246,byte 246,byte 229,byte 229,byte 212,byte 245, + byte 245,byte 228,byte 228,byte 211,byte 244,byte 227,byte 210,byte 193, + byte 213,byte 213,byte 229,byte 229,byte 212,byte 212,byte 212,byte 195, + byte 228,byte 228,byte 211,byte 211,byte 194,byte 227,byte 210,byte 193, + byte 196,byte 196,byte 242,byte 242,byte 212,byte 195,byte 195,byte 241, + byte 241,byte 211,byte 211,byte 194,byte 194,byte 240,byte 210,byte 193, + byte 243,byte 243,byte 242,byte 242,byte 242,byte 195,byte 195,byte 241, + byte 241,byte 241,byte 194,byte 194,byte 240,byte 240,byte 239,byte 205, + byte 226,byte 226,byte 242,byte 242,byte 225,byte 225,byte 195,byte 241, + byte 241,byte 224,byte 224,byte 240,byte 240,byte 239,byte 239,byte 205, + byte 209,byte 209,byte 225,byte 225,byte 208,byte 208,byte 208,byte 224, + byte 224,byte 223,byte 223,byte 223,byte 239,byte 239,byte 222,byte 205, + byte 192,byte 192,byte 192,byte 192,byte 207,byte 207,byte 207,byte 207, + byte 206,byte 206,byte 206,byte 206,byte 205,byte 205,byte 205,byte 205, + byte 255,byte 255,byte 255,byte 254,byte 254,byte 237,byte 220,byte 203, + byte 253,byte 236,byte 219,byte 202,byte 252,byte 235,byte 218,byte 201, + byte 255,byte 238,byte 221,byte 221,byte 254,byte 237,byte 220,byte 203, + byte 253,byte 236,byte 219,byte 202,byte 252,byte 235,byte 218,byte 201, + byte 255,byte 221,byte 221,byte 221,byte 204,byte 250,byte 220,byte 249, + byte 249,byte 249,byte 232,byte 248,byte 248,byte 248,byte 231,byte 201, + byte 251,byte 221,byte 221,byte 204,byte 250,byte 250,byte 249,byte 249, + byte 249,byte 249,byte 232,byte 248,byte 248,byte 248,byte 231,byte 201, + byte 251,byte 251,byte 204,byte 250,byte 250,byte 233,byte 233,byte 249, + byte 249,byte 232,byte 215,byte 215,byte 248,byte 231,byte 214,byte 197, + byte 234,byte 234,byte 250,byte 250,byte 233,byte 233,byte 216,byte 216, + byte 249,byte 232,byte 215,byte 198,byte 198,byte 231,byte 214,byte 197, + byte 217,byte 217,byte 217,byte 246,byte 233,byte 216,byte 216,byte 199, + byte 199,byte 215,byte 215,byte 198,byte 198,byte 198,byte 214,byte 197, + byte 200,byte 200,byte 246,byte 246,byte 246,byte 216,byte 199,byte 199, + byte 245,byte 245,byte 198,byte 244,byte 244,byte 244,byte 227,byte 197, + byte 247,byte 247,byte 246,byte 246,byte 246,byte 246,byte 199,byte 245, + byte 245,byte 245,byte 228,byte 244,byte 244,byte 244,byte 227,byte 193, + byte 230,byte 230,byte 246,byte 246,byte 229,byte 229,byte 212,byte 245, + byte 245,byte 228,byte 228,byte 211,byte 244,byte 227,byte 210,byte 193, + byte 213,byte 213,byte 229,byte 229,byte 212,byte 212,byte 212,byte 195, + byte 228,byte 228,byte 211,byte 211,byte 194,byte 227,byte 210,byte 193, + byte 196,byte 196,byte 242,byte 242,byte 212,byte 195,byte 195,byte 241, + byte 241,byte 211,byte 211,byte 194,byte 194,byte 240,byte 210,byte 193, + byte 243,byte 243,byte 242,byte 242,byte 242,byte 195,byte 195,byte 241, + byte 241,byte 241,byte 194,byte 194,byte 240,byte 240,byte 239,byte 205, + byte 226,byte 226,byte 242,byte 242,byte 225,byte 225,byte 195,byte 241, + byte 241,byte 224,byte 224,byte 240,byte 240,byte 239,byte 239,byte 205, + byte 209,byte 209,byte 225,byte 225,byte 208,byte 208,byte 208,byte 224, + byte 224,byte 223,byte 223,byte 223,byte 239,byte 239,byte 222,byte 205, + byte 192,byte 192,byte 192,byte 192,byte 207,byte 207,byte 207,byte 207, + byte 206,byte 206,byte 206,byte 206,byte 205,byte 205,byte 205,byte 205, + byte 255,byte 255,byte 255,byte 191,byte 191,byte 191,byte 220,byte 190, + byte 190,byte 190,byte 173,byte 189,byte 189,byte 189,byte 172,byte 201, + byte 255,byte 221,byte 221,byte 221,byte 204,byte 191,byte 220,byte 190, + byte 190,byte 190,byte 173,byte 189,byte 189,byte 189,byte 172,byte 201, + byte 255,byte 221,byte 221,byte 204,byte 204,byte 204,byte 186,byte 186, + byte 186,byte 186,byte 186,byte 185,byte 185,byte 185,byte 168,byte 201, + byte 188,byte 221,byte 204,byte 204,byte 204,byte 187,byte 186,byte 186, + byte 186,byte 186,byte 232,byte 185,byte 185,byte 185,byte 168,byte 201, + byte 188,byte 204,byte 204,byte 204,byte 187,byte 187,byte 186,byte 186, + byte 186,byte 186,byte 169,byte 185,byte 185,byte 185,byte 168,byte 197, + byte 188,byte 188,byte 204,byte 187,byte 187,byte 233,byte 216,byte 186, + byte 186,byte 186,byte 215,byte 185,byte 185,byte 185,byte 168,byte 197, + byte 217,byte 217,byte 183,byte 183,byte 183,byte 216,byte 216,byte 199, + byte 182,byte 182,byte 215,byte 198,byte 198,byte 181,byte 214,byte 197, + byte 184,byte 184,byte 183,byte 183,byte 183,byte 183,byte 199,byte 182, + byte 182,byte 182,byte 182,byte 181,byte 181,byte 181,byte 181,byte 197, + byte 184,byte 184,byte 183,byte 183,byte 183,byte 183,byte 182,byte 182, + byte 182,byte 182,byte 182,byte 181,byte 181,byte 181,byte 164,byte 193, + byte 184,byte 184,byte 183,byte 183,byte 183,byte 183,byte 182,byte 182, + byte 182,byte 228,byte 165,byte 181,byte 181,byte 164,byte 164,byte 193, + byte 167,byte 167,byte 183,byte 229,byte 166,byte 212,byte 212,byte 182, + byte 182,byte 165,byte 211,byte 211,byte 181,byte 164,byte 210,byte 193, + byte 180,byte 180,byte 179,byte 179,byte 179,byte 179,byte 195,byte 178, + byte 178,byte 178,byte 211,byte 194,byte 177,byte 177,byte 177,byte 193, + byte 180,byte 180,byte 179,byte 179,byte 179,byte 179,byte 195,byte 178, + byte 178,byte 178,byte 178,byte 177,byte 177,byte 177,byte 177,byte 205, + byte 180,byte 180,byte 179,byte 179,byte 179,byte 179,byte 178,byte 178, + byte 178,byte 161,byte 161,byte 177,byte 177,byte 177,byte 160,byte 205, + byte 163,byte 163,byte 162,byte 162,byte 162,byte 162,byte 208,byte 178, + byte 161,byte 161,byte 223,byte 177,byte 177,byte 160,byte 160,byte 205, + byte 192,byte 192,byte 192,byte 192,byte 207,byte 207,byte 207,byte 207, + byte 206,byte 206,byte 206,byte 206,byte 205,byte 205,byte 205,byte 205, + byte 176,byte 176,byte 191,byte 191,byte 191,byte 191,byte 190,byte 190, + byte 190,byte 190,byte 173,byte 189,byte 189,byte 189,byte 172,byte 201, + byte 176,byte 221,byte 221,byte 204,byte 191,byte 191,byte 190,byte 190, + byte 190,byte 190,byte 173,byte 189,byte 189,byte 189,byte 172,byte 201, + byte 188,byte 221,byte 204,byte 204,byte 204,byte 187,byte 186,byte 186, + byte 186,byte 186,byte 173,byte 185,byte 185,byte 185,byte 168,byte 201, + byte 188,byte 204,byte 204,byte 204,byte 187,byte 187,byte 186,byte 186, + byte 186,byte 186,byte 169,byte 185,byte 185,byte 185,byte 168,byte 201, + byte 188,byte 188,byte 204,byte 187,byte 187,byte 187,byte 186,byte 186, + byte 186,byte 186,byte 169,byte 185,byte 185,byte 185,byte 168,byte 197, + byte 188,byte 188,byte 187,byte 187,byte 187,byte 170,byte 170,byte 186, + byte 186,byte 169,byte 169,byte 185,byte 185,byte 168,byte 168,byte 197, + byte 184,byte 184,byte 183,byte 183,byte 183,byte 170,byte 170,byte 182, + byte 182,byte 169,byte 152,byte 152,byte 181,byte 168,byte 151,byte 197, + byte 184,byte 184,byte 183,byte 183,byte 183,byte 183,byte 182,byte 182, + byte 182,byte 182,byte 182,byte 181,byte 181,byte 181,byte 164,byte 197, + byte 184,byte 184,byte 183,byte 183,byte 183,byte 183,byte 182,byte 182, + byte 182,byte 182,byte 165,byte 181,byte 181,byte 181,byte 164,byte 193, + byte 184,byte 184,byte 183,byte 183,byte 183,byte 166,byte 166,byte 182, + byte 182,byte 165,byte 165,byte 181,byte 181,byte 164,byte 164,byte 193, + byte 167,byte 167,byte 167,byte 166,byte 166,byte 166,byte 149,byte 182, + byte 165,byte 165,byte 165,byte 148,byte 181,byte 164,byte 147,byte 193, + byte 180,byte 180,byte 179,byte 179,byte 179,byte 179,byte 149,byte 178, + byte 178,byte 178,byte 148,byte 177,byte 177,byte 177,byte 147,byte 193, + byte 180,byte 180,byte 179,byte 179,byte 179,byte 179,byte 178,byte 178, + byte 178,byte 178,byte 178,byte 177,byte 177,byte 177,byte 160,byte 205, + byte 180,byte 180,byte 179,byte 179,byte 179,byte 162,byte 162,byte 178, + byte 178,byte 161,byte 161,byte 177,byte 177,byte 160,byte 160,byte 205, + byte 163,byte 163,byte 162,byte 162,byte 162,byte 162,byte 145,byte 161, + byte 161,byte 161,byte 144,byte 144,byte 160,byte 160,byte 160,byte 205, + byte 192,byte 192,byte 192,byte 192,byte 207,byte 207,byte 207,byte 207, + byte 206,byte 206,byte 206,byte 206,byte 205,byte 205,byte 205,byte 205, + byte 176,byte 176,byte 191,byte 191,byte 191,byte 174,byte 174,byte 190, + byte 190,byte 173,byte 156,byte 156,byte 189,byte 172,byte 155,byte 138, + byte 176,byte 176,byte 204,byte 191,byte 191,byte 174,byte 174,byte 190, + byte 190,byte 173,byte 156,byte 156,byte 189,byte 172,byte 155,byte 138, + byte 188,byte 204,byte 204,byte 204,byte 187,byte 187,byte 186,byte 186, + byte 186,byte 186,byte 169,byte 185,byte 185,byte 185,byte 168,byte 138, + byte 188,byte 188,byte 204,byte 187,byte 187,byte 187,byte 186,byte 186, + byte 186,byte 186,byte 169,byte 185,byte 185,byte 185,byte 168,byte 138, + byte 188,byte 188,byte 187,byte 187,byte 187,byte 170,byte 170,byte 186, + byte 186,byte 169,byte 169,byte 185,byte 185,byte 168,byte 151,byte 134, + byte 171,byte 171,byte 187,byte 187,byte 170,byte 170,byte 170,byte 186, + byte 186,byte 169,byte 152,byte 152,byte 185,byte 168,byte 151,byte 134, + byte 171,byte 171,byte 183,byte 183,byte 170,byte 170,byte 170,byte 153, + byte 182,byte 169,byte 152,byte 135,byte 135,byte 168,byte 151,byte 134, + byte 184,byte 184,byte 183,byte 183,byte 183,byte 183,byte 153,byte 182, + byte 182,byte 182,byte 182,byte 181,byte 181,byte 181,byte 164,byte 134, + byte 184,byte 184,byte 183,byte 183,byte 183,byte 183,byte 182,byte 182, + byte 182,byte 182,byte 165,byte 181,byte 181,byte 181,byte 164,byte 130, + byte 167,byte 167,byte 183,byte 183,byte 166,byte 166,byte 166,byte 182, + byte 182,byte 165,byte 165,byte 181,byte 181,byte 164,byte 147,byte 130, + byte 150,byte 150,byte 166,byte 166,byte 166,byte 149,byte 149,byte 182, + byte 165,byte 165,byte 148,byte 148,byte 164,byte 164,byte 147,byte 130, + byte 150,byte 150,byte 179,byte 179,byte 179,byte 149,byte 132,byte 178, + byte 178,byte 178,byte 148,byte 131,byte 177,byte 177,byte 147,byte 130, + byte 180,byte 180,byte 179,byte 179,byte 179,byte 179,byte 132,byte 178, + byte 178,byte 178,byte 161,byte 177,byte 177,byte 177,byte 160,byte 142, + byte 163,byte 163,byte 179,byte 179,byte 162,byte 162,byte 162,byte 178, + byte 178,byte 161,byte 161,byte 177,byte 177,byte 160,byte 160,byte 142, + byte 146,byte 146,byte 162,byte 162,byte 145,byte 145,byte 145,byte 161, + byte 161,byte 144,byte 144,byte 144,byte 160,byte 160,byte 159,byte 142, + byte 129,byte 129,byte 129,byte 129,byte 128,byte 128,byte 128,byte 128, + byte 143,byte 143,byte 143,byte 143,byte 142,byte 142,byte 142,byte 142, + byte 175,byte 175,byte 191,byte 191,byte 174,byte 174,byte 157,byte 157, + byte 190,byte 173,byte 156,byte 139,byte 139,byte 172,byte 155,byte 138, + byte 175,byte 175,byte 191,byte 191,byte 174,byte 174,byte 157,byte 157, + byte 190,byte 173,byte 156,byte 139,byte 139,byte 172,byte 155,byte 138, + byte 188,byte 188,byte 204,byte 187,byte 187,byte 187,byte 157,byte 186, + byte 186,byte 186,byte 156,byte 185,byte 185,byte 185,byte 168,byte 138, + byte 188,byte 188,byte 187,byte 187,byte 187,byte 170,byte 170,byte 186, + byte 186,byte 169,byte 169,byte 185,byte 185,byte 168,byte 168,byte 138, + byte 171,byte 171,byte 187,byte 187,byte 170,byte 170,byte 170,byte 186, + byte 186,byte 169,byte 152,byte 152,byte 185,byte 168,byte 151,byte 134, + byte 171,byte 171,byte 187,byte 170,byte 170,byte 170,byte 170,byte 153, + byte 169,byte 169,byte 152,byte 135,byte 135,byte 168,byte 151,byte 134, + byte 154,byte 154,byte 154,byte 170,byte 170,byte 170,byte 153,byte 153, + byte 169,byte 152,byte 152,byte 135,byte 135,byte 135,byte 151,byte 134, + byte 154,byte 154,byte 183,byte 183,byte 183,byte 153,byte 153,byte 153, + byte 182,byte 182,byte 135,byte 135,byte 181,byte 181,byte 164,byte 134, + byte 184,byte 184,byte 183,byte 183,byte 183,byte 166,byte 166,byte 182, + byte 182,byte 165,byte 165,byte 181,byte 181,byte 164,byte 164,byte 130, + byte 167,byte 167,byte 183,byte 166,byte 166,byte 166,byte 149,byte 182, + byte 165,byte 165,byte 165,byte 148,byte 181,byte 164,byte 147,byte 130, + byte 150,byte 150,byte 150,byte 166,byte 149,byte 149,byte 149,byte 132, + byte 165,byte 165,byte 148,byte 148,byte 131,byte 147,byte 147,byte 130, + byte 133,byte 133,byte 179,byte 179,byte 149,byte 132,byte 132,byte 132, + byte 178,byte 148,byte 148,byte 131,byte 131,byte 131,byte 130,byte 130, + byte 133,byte 133,byte 179,byte 179,byte 179,byte 132,byte 132,byte 178, + byte 178,byte 178,byte 131,byte 131,byte 131,byte 177,byte 160,byte 142, + byte 163,byte 163,byte 179,byte 162,byte 162,byte 162,byte 132,byte 178, + byte 161,byte 161,byte 144,byte 131,byte 177,byte 160,byte 160,byte 142, + byte 146,byte 146,byte 162,byte 162,byte 145,byte 145,byte 145,byte 161, + byte 161,byte 144,byte 144,byte 143,byte 160,byte 160,byte 159,byte 142, + byte 129,byte 129,byte 129,byte 129,byte 128,byte 128,byte 128,byte 128, + byte 143,byte 143,byte 143,byte 143,byte 142,byte 142,byte 142,byte 142, + byte 158,byte 158,byte 158,byte 112,byte 174,byte 157,byte 157,byte 140, + byte 140,byte 156,byte 156,byte 139,byte 139,byte 139,byte 155,byte 138, + byte 158,byte 158,byte 158,byte 112,byte 174,byte 157,byte 157,byte 140, + byte 140,byte 156,byte 156,byte 139,byte 139,byte 139,byte 155,byte 138, + byte 158,byte 158,byte 124,byte 124,byte 124,byte 157,byte 157,byte 140, + byte 123,byte 123,byte 156,byte 139,byte 139,byte 122,byte 155,byte 138, + byte 125,byte 125,byte 124,byte 124,byte 124,byte 170,byte 170,byte 123, + byte 123,byte 169,byte 152,byte 152,byte 122,byte 168,byte 151,byte 138, + byte 171,byte 171,byte 124,byte 124,byte 170,byte 170,byte 170,byte 153, + byte 123,byte 169,byte 152,byte 135,byte 135,byte 168,byte 151,byte 134, + byte 154,byte 154,byte 154,byte 170,byte 170,byte 170,byte 153,byte 153, + byte 169,byte 152,byte 152,byte 135,byte 135,byte 135,byte 151,byte 134, + byte 154,byte 154,byte 154,byte 170,byte 170,byte 153,byte 153,byte 153, + byte 136,byte 152,byte 135,byte 135,byte 135,byte 135,byte 134,byte 134, + byte 137,byte 137,byte 137,byte 120,byte 153,byte 153,byte 153,byte 136, + byte 136,byte 136,byte 135,byte 135,byte 135,byte 118,byte 164,byte 134, + byte 137,byte 137,byte 120,byte 120,byte 120,byte 166,byte 136,byte 136, + byte 136,byte 165,byte 165,byte 118,byte 118,byte 164,byte 147,byte 130, + byte 150,byte 150,byte 120,byte 166,byte 166,byte 149,byte 149,byte 136, + byte 165,byte 165,byte 148,byte 148,byte 118,byte 164,byte 147,byte 130, + byte 150,byte 150,byte 150,byte 149,byte 149,byte 149,byte 132,byte 132, + byte 165,byte 148,byte 148,byte 131,byte 131,byte 147,byte 147,byte 130, + byte 133,byte 133,byte 133,byte 149,byte 132,byte 132,byte 132,byte 132, + byte 115,byte 148,byte 131,byte 131,byte 131,byte 131,byte 130,byte 130, + byte 133,byte 133,byte 133,byte 116,byte 132,byte 132,byte 132,byte 132, + byte 115,byte 115,byte 131,byte 131,byte 131,byte 131,byte 160,byte 142, + byte 133,byte 133,byte 116,byte 162,byte 162,byte 132,byte 132,byte 115, + byte 161,byte 161,byte 144,byte 131,byte 131,byte 160,byte 160,byte 142, + byte 146,byte 146,byte 146,byte 145,byte 145,byte 145,byte 128,byte 161, + byte 144,byte 144,byte 144,byte 143,byte 160,byte 160,byte 159,byte 142, + byte 129,byte 129,byte 129,byte 129,byte 128,byte 128,byte 128,byte 128, + byte 143,byte 143,byte 143,byte 143,byte 142,byte 142,byte 142,byte 142, + byte 141,byte 141,byte 112,byte 112,byte 112,byte 157,byte 140,byte 140, + byte 140,byte 127,byte 139,byte 126,byte 126,byte 126,byte 109,byte 138, + byte 141,byte 141,byte 112,byte 112,byte 112,byte 157,byte 140,byte 140, + byte 140,byte 127,byte 139,byte 126,byte 126,byte 126,byte 109,byte 138, + byte 125,byte 125,byte 124,byte 124,byte 124,byte 124,byte 140,byte 123, + byte 123,byte 123,byte 123,byte 122,byte 122,byte 122,byte 122,byte 138, + byte 125,byte 125,byte 124,byte 124,byte 124,byte 124,byte 123,byte 123, + byte 123,byte 123,byte 123,byte 122,byte 122,byte 122,byte 105,byte 138, + byte 125,byte 125,byte 124,byte 124,byte 124,byte 124,byte 153,byte 123, + byte 123,byte 123,byte 152,byte 122,byte 122,byte 122,byte 105,byte 134, + byte 154,byte 154,byte 124,byte 124,byte 124,byte 153,byte 153,byte 153, + byte 123,byte 123,byte 135,byte 135,byte 122,byte 122,byte 105,byte 134, + byte 137,byte 137,byte 137,byte 120,byte 153,byte 153,byte 153,byte 136, + byte 136,byte 136,byte 135,byte 135,byte 135,byte 118,byte 105,byte 134, + byte 137,byte 137,byte 120,byte 120,byte 120,byte 153,byte 136,byte 136, + byte 136,byte 119,byte 119,byte 118,byte 118,byte 118,byte 118,byte 134, + byte 137,byte 137,byte 120,byte 120,byte 120,byte 120,byte 136,byte 136, + byte 119,byte 119,byte 119,byte 118,byte 118,byte 118,byte 101,byte 130, + byte 121,byte 121,byte 120,byte 120,byte 120,byte 120,byte 136,byte 119, + byte 119,byte 119,byte 102,byte 118,byte 118,byte 118,byte 101,byte 130, + byte 133,byte 133,byte 120,byte 120,byte 149,byte 132,byte 132,byte 119, + byte 119,byte 102,byte 148,byte 131,byte 131,byte 101,byte 101,byte 130, + byte 117,byte 117,byte 116,byte 116,byte 116,byte 132,byte 132,byte 115, + byte 115,byte 115,byte 131,byte 131,byte 114,byte 114,byte 114,byte 130, + byte 117,byte 117,byte 116,byte 116,byte 116,byte 116,byte 132,byte 115, + byte 115,byte 115,byte 131,byte 114,byte 114,byte 114,byte 114,byte 142, + byte 117,byte 117,byte 116,byte 116,byte 116,byte 116,byte 115,byte 115, + byte 115,byte 115,byte 98,byte 114,byte 114,byte 114,byte 97,byte 142, + byte 100,byte 100,byte 116,byte 99,byte 99,byte 99,byte 99,byte 115, + byte 98,byte 98,byte 98,byte 114,byte 114,byte 97,byte 97,byte 142, + byte 129,byte 129,byte 129,byte 129,byte 128,byte 128,byte 128,byte 128, + byte 143,byte 143,byte 143,byte 143,byte 142,byte 142,byte 142,byte 142, + byte 113,byte 113,byte 112,byte 112,byte 112,byte 112,byte 140,byte 140, + byte 127,byte 127,byte 110,byte 126,byte 126,byte 126,byte 109,byte 75, + byte 113,byte 113,byte 112,byte 112,byte 112,byte 112,byte 140,byte 140, + byte 127,byte 127,byte 110,byte 126,byte 126,byte 126,byte 109,byte 75, + byte 125,byte 125,byte 124,byte 124,byte 124,byte 124,byte 123,byte 123, + byte 123,byte 123,byte 123,byte 122,byte 122,byte 122,byte 105,byte 75, + byte 125,byte 125,byte 124,byte 124,byte 124,byte 124,byte 123,byte 123, + byte 123,byte 123,byte 106,byte 122,byte 122,byte 122,byte 105,byte 75, + byte 125,byte 125,byte 124,byte 124,byte 124,byte 124,byte 123,byte 123, + byte 123,byte 123,byte 106,byte 122,byte 122,byte 122,byte 105,byte 71, + byte 125,byte 125,byte 124,byte 124,byte 124,byte 107,byte 107,byte 123, + byte 123,byte 106,byte 106,byte 122,byte 122,byte 105,byte 105,byte 71, + byte 137,byte 137,byte 120,byte 120,byte 120,byte 107,byte 136,byte 136, + byte 136,byte 106,byte 106,byte 118,byte 118,byte 105,byte 88,byte 71, + byte 137,byte 137,byte 120,byte 120,byte 120,byte 120,byte 136,byte 136, + byte 119,byte 119,byte 119,byte 118,byte 118,byte 118,byte 101,byte 71, + byte 121,byte 121,byte 120,byte 120,byte 120,byte 120,byte 136,byte 119, + byte 119,byte 119,byte 102,byte 118,byte 118,byte 118,byte 101,byte 67, + byte 121,byte 121,byte 120,byte 120,byte 120,byte 103,byte 103,byte 119, + byte 119,byte 102,byte 102,byte 118,byte 118,byte 101,byte 101,byte 67, + byte 104,byte 104,byte 120,byte 103,byte 103,byte 103,byte 103,byte 119, + byte 102,byte 102,byte 102,byte 118,byte 118,byte 101,byte 84,byte 67, + byte 117,byte 117,byte 116,byte 116,byte 116,byte 116,byte 115,byte 115, + byte 115,byte 115,byte 115,byte 114,byte 114,byte 114,byte 114,byte 67, + byte 117,byte 117,byte 116,byte 116,byte 116,byte 116,byte 115,byte 115, + byte 115,byte 115,byte 115,byte 114,byte 114,byte 114,byte 97,byte 79, + byte 117,byte 117,byte 116,byte 116,byte 116,byte 99,byte 99,byte 115, + byte 115,byte 98,byte 98,byte 114,byte 114,byte 97,byte 97,byte 79, + byte 100,byte 100,byte 99,byte 99,byte 99,byte 99,byte 82,byte 98, + byte 98,byte 98,byte 81,byte 114,byte 97,byte 97,byte 97,byte 79, + byte 66,byte 66,byte 66,byte 66,byte 65,byte 65,byte 65,byte 65, + byte 64,byte 64,byte 64,byte 64,byte 79,byte 79,byte 79,byte 79, + byte 96,byte 96,byte 112,byte 112,byte 111,byte 111,byte 94,byte 127, + byte 127,byte 110,byte 110,byte 93,byte 126,byte 109,byte 92,byte 75, + byte 96,byte 96,byte 112,byte 112,byte 111,byte 111,byte 94,byte 127, + byte 127,byte 110,byte 110,byte 93,byte 126,byte 109,byte 92,byte 75, + byte 125,byte 125,byte 124,byte 124,byte 124,byte 124,byte 123,byte 123, + byte 123,byte 123,byte 106,byte 122,byte 122,byte 105,byte 105,byte 75, + byte 125,byte 125,byte 124,byte 124,byte 124,byte 107,byte 107,byte 123, + byte 123,byte 106,byte 106,byte 122,byte 122,byte 105,byte 105,byte 75, + byte 108,byte 108,byte 124,byte 124,byte 107,byte 107,byte 107,byte 123, + byte 123,byte 106,byte 106,byte 122,byte 122,byte 105,byte 88,byte 71, + byte 108,byte 108,byte 124,byte 107,byte 107,byte 107,byte 90,byte 123, + byte 106,byte 106,byte 106,byte 89,byte 122,byte 105,byte 88,byte 71, + byte 91,byte 91,byte 120,byte 107,byte 107,byte 90,byte 90,byte 136, + byte 106,byte 106,byte 89,byte 89,byte 118,byte 105,byte 88,byte 71, + byte 121,byte 121,byte 120,byte 120,byte 120,byte 120,byte 136,byte 119, + byte 119,byte 119,byte 102,byte 118,byte 118,byte 118,byte 101,byte 71, + byte 121,byte 121,byte 120,byte 120,byte 120,byte 103,byte 103,byte 119, + byte 119,byte 102,byte 102,byte 118,byte 118,byte 101,byte 101,byte 67, + byte 104,byte 104,byte 120,byte 103,byte 103,byte 103,byte 103,byte 119, + byte 102,byte 102,byte 102,byte 118,byte 118,byte 101,byte 84,byte 67, + byte 104,byte 104,byte 103,byte 103,byte 103,byte 103,byte 86,byte 102, + byte 102,byte 102,byte 85,byte 85,byte 101,byte 101,byte 84,byte 67, + byte 87,byte 87,byte 116,byte 116,byte 116,byte 86,byte 86,byte 115, + byte 115,byte 115,byte 85,byte 85,byte 114,byte 114,byte 84,byte 67, + byte 117,byte 117,byte 116,byte 116,byte 116,byte 116,byte 115,byte 115, + byte 115,byte 115,byte 98,byte 114,byte 114,byte 114,byte 97,byte 79, + byte 100,byte 100,byte 99,byte 99,byte 99,byte 99,byte 99,byte 115, + byte 98,byte 98,byte 98,byte 114,byte 114,byte 97,byte 97,byte 79, + byte 83,byte 83,byte 99,byte 99,byte 82,byte 82,byte 82,byte 98, + byte 98,byte 81,byte 81,byte 81,byte 97,byte 97,byte 80,byte 79, + byte 66,byte 66,byte 66,byte 66,byte 65,byte 65,byte 65,byte 65, + byte 64,byte 64,byte 64,byte 64,byte 79,byte 79,byte 79,byte 79, + byte 95,byte 95,byte 111,byte 111,byte 94,byte 94,byte 94,byte 77, + byte 110,byte 110,byte 93,byte 93,byte 76,byte 109,byte 92,byte 75, + byte 95,byte 95,byte 111,byte 111,byte 94,byte 94,byte 94,byte 77, + byte 110,byte 110,byte 93,byte 93,byte 76,byte 109,byte 92,byte 75, + byte 108,byte 108,byte 124,byte 111,byte 107,byte 94,byte 94,byte 123, + byte 123,byte 106,byte 93,byte 93,byte 122,byte 105,byte 92,byte 75, + byte 108,byte 108,byte 108,byte 107,byte 107,byte 107,byte 90,byte 123, + byte 106,byte 106,byte 106,byte 89,byte 122,byte 105,byte 88,byte 75, + byte 91,byte 91,byte 107,byte 107,byte 107,byte 90,byte 90,byte 123, + byte 106,byte 106,byte 89,byte 89,byte 105,byte 105,byte 88,byte 71, + byte 91,byte 91,byte 91,byte 107,byte 90,byte 90,byte 90,byte 73, + byte 106,byte 106,byte 89,byte 89,byte 72,byte 88,byte 88,byte 71, + byte 91,byte 91,byte 91,byte 90,byte 90,byte 90,byte 73,byte 73, + byte 106,byte 89,byte 89,byte 72,byte 72,byte 88,byte 88,byte 71, + byte 74,byte 74,byte 120,byte 120,byte 120,byte 73,byte 73,byte 119, + byte 119,byte 102,byte 89,byte 72,byte 72,byte 101,byte 101,byte 71, + byte 104,byte 104,byte 120,byte 103,byte 103,byte 103,byte 103,byte 119, + byte 102,byte 102,byte 102,byte 118,byte 118,byte 101,byte 84,byte 67, + byte 104,byte 104,byte 103,byte 103,byte 103,byte 103,byte 86,byte 102, + byte 102,byte 102,byte 85,byte 85,byte 101,byte 101,byte 84,byte 67, + byte 87,byte 87,byte 87,byte 103,byte 86,byte 86,byte 86,byte 86, + byte 102,byte 85,byte 85,byte 85,byte 85,byte 84,byte 84,byte 67, + byte 87,byte 87,byte 87,byte 86,byte 86,byte 86,byte 69,byte 69, + byte 115,byte 85,byte 85,byte 85,byte 68,byte 68,byte 67,byte 67, + byte 70,byte 70,byte 116,byte 116,byte 99,byte 69,byte 69,byte 69, + byte 115,byte 98,byte 85,byte 68,byte 68,byte 97,byte 97,byte 79, + byte 100,byte 100,byte 99,byte 99,byte 99,byte 82,byte 82,byte 98, + byte 98,byte 98,byte 81,byte 68,byte 97,byte 97,byte 97,byte 79, + byte 83,byte 83,byte 83,byte 82,byte 82,byte 82,byte 82,byte 98, + byte 81,byte 81,byte 81,byte 64,byte 97,byte 97,byte 80,byte 79, + byte 66,byte 66,byte 66,byte 66,byte 65,byte 65,byte 65,byte 65, + byte 64,byte 64,byte 64,byte 64,byte 79,byte 79,byte 79,byte 79, + byte 78,byte 78,byte 49,byte 49,byte 94,byte 77,byte 77,byte 48, + byte 48,byte 93,byte 93,byte 76,byte 76,byte 63,byte 92,byte 75, + byte 78,byte 78,byte 49,byte 49,byte 94,byte 77,byte 77,byte 48, + byte 48,byte 93,byte 93,byte 76,byte 76,byte 63,byte 92,byte 75, + byte 62,byte 62,byte 61,byte 61,byte 61,byte 61,byte 77,byte 60, + byte 60,byte 60,byte 93,byte 76,byte 59,byte 59,byte 59,byte 75, + byte 62,byte 62,byte 61,byte 61,byte 61,byte 61,byte 90,byte 60, + byte 60,byte 60,byte 89,byte 59,byte 59,byte 59,byte 88,byte 75, + byte 91,byte 91,byte 61,byte 61,byte 61,byte 90,byte 73,byte 60, + byte 60,byte 60,byte 89,byte 72,byte 59,byte 59,byte 88,byte 71, + byte 74,byte 74,byte 61,byte 61,byte 90,byte 73,byte 73,byte 73, + byte 60,byte 89,byte 89,byte 72,byte 72,byte 72,byte 71,byte 71, + byte 74,byte 74,byte 74,byte 90,byte 73,byte 73,byte 73,byte 73, + byte 56,byte 89,byte 72,byte 72,byte 72,byte 72,byte 71,byte 71, + byte 58,byte 58,byte 57,byte 57,byte 57,byte 73,byte 73,byte 56, + byte 56,byte 56,byte 72,byte 72,byte 55,byte 55,byte 55,byte 71, + byte 58,byte 58,byte 57,byte 57,byte 57,byte 57,byte 56,byte 56, + byte 56,byte 56,byte 56,byte 55,byte 55,byte 55,byte 55,byte 67, + byte 87,byte 87,byte 57,byte 57,byte 57,byte 86,byte 86,byte 56, + byte 56,byte 56,byte 85,byte 85,byte 55,byte 55,byte 84,byte 67, + byte 87,byte 87,byte 87,byte 86,byte 86,byte 86,byte 69,byte 69, + byte 56,byte 85,byte 85,byte 85,byte 68,byte 68,byte 67,byte 67, + byte 70,byte 70,byte 70,byte 53,byte 69,byte 69,byte 69,byte 69, + byte 52,byte 85,byte 85,byte 68,byte 68,byte 68,byte 67,byte 67, + byte 70,byte 70,byte 53,byte 53,byte 53,byte 69,byte 69,byte 52, + byte 52,byte 52,byte 68,byte 68,byte 68,byte 51,byte 51,byte 79, + byte 54,byte 54,byte 53,byte 53,byte 53,byte 69,byte 69,byte 52, + byte 52,byte 52,byte 68,byte 68,byte 51,byte 51,byte 80,byte 79, + byte 83,byte 83,byte 53,byte 82,byte 82,byte 65,byte 65,byte 52, + byte 52,byte 81,byte 64,byte 64,byte 51,byte 80,byte 80,byte 79, + byte 66,byte 66,byte 66,byte 66,byte 65,byte 65,byte 65,byte 65, + byte 64,byte 64,byte 64,byte 64,byte 79,byte 79,byte 79,byte 79, + byte 50,byte 50,byte 49,byte 49,byte 49,byte 77,byte 77,byte 48, + byte 48,byte 48,byte 76,byte 76,byte 63,byte 63,byte 46,byte 12, + byte 50,byte 50,byte 49,byte 49,byte 49,byte 77,byte 77,byte 48, + byte 48,byte 48,byte 76,byte 76,byte 63,byte 63,byte 46,byte 12, + byte 62,byte 62,byte 61,byte 61,byte 61,byte 61,byte 77,byte 60, + byte 60,byte 60,byte 60,byte 59,byte 59,byte 59,byte 59,byte 12, + byte 62,byte 62,byte 61,byte 61,byte 61,byte 61,byte 60,byte 60, + byte 60,byte 60,byte 60,byte 59,byte 59,byte 59,byte 42,byte 12, + byte 62,byte 62,byte 61,byte 61,byte 61,byte 61,byte 73,byte 60, + byte 60,byte 60,byte 43,byte 59,byte 59,byte 59,byte 42,byte 8, + byte 74,byte 74,byte 61,byte 61,byte 61,byte 73,byte 73,byte 60, + byte 60,byte 60,byte 72,byte 72,byte 72,byte 59,byte 42,byte 8, + byte 74,byte 74,byte 74,byte 57,byte 73,byte 73,byte 73,byte 73, + byte 56,byte 56,byte 72,byte 72,byte 72,byte 72,byte 42,byte 8, + byte 58,byte 58,byte 57,byte 57,byte 57,byte 57,byte 73,byte 56, + byte 56,byte 56,byte 72,byte 55,byte 55,byte 55,byte 55,byte 8, + byte 58,byte 58,byte 57,byte 57,byte 57,byte 57,byte 56,byte 56, + byte 56,byte 56,byte 56,byte 55,byte 55,byte 55,byte 38,byte 4, + byte 58,byte 58,byte 57,byte 57,byte 57,byte 57,byte 56,byte 56, + byte 56,byte 56,byte 39,byte 55,byte 55,byte 55,byte 38,byte 4, + byte 70,byte 70,byte 57,byte 57,byte 40,byte 69,byte 69,byte 69, + byte 56,byte 39,byte 85,byte 68,byte 68,byte 38,byte 38,byte 4, + byte 70,byte 70,byte 53,byte 53,byte 53,byte 69,byte 69,byte 52, + byte 52,byte 52,byte 68,byte 68,byte 68,byte 51,byte 51,byte 4, + byte 54,byte 54,byte 53,byte 53,byte 53,byte 69,byte 69,byte 52, + byte 52,byte 52,byte 68,byte 68,byte 51,byte 51,byte 51,byte 0, + byte 54,byte 54,byte 53,byte 53,byte 53,byte 53,byte 69,byte 52, + byte 52,byte 52,byte 35,byte 51,byte 51,byte 51,byte 34,byte 0, + byte 37,byte 37,byte 53,byte 36,byte 36,byte 36,byte 36,byte 52, + byte 35,byte 35,byte 35,byte 51,byte 51,byte 34,byte 34,byte 0, + byte 3,byte 3,byte 3,byte 3,byte 2,byte 2,byte 2,byte 2, + byte 1,byte 1,byte 1,byte 1,byte 0,byte 0,byte 0,byte 0, + byte 33,byte 33,byte 49,byte 49,byte 32,byte 32,byte 77,byte 48, + byte 48,byte 47,byte 47,byte 63,byte 63,byte 46,byte 46,byte 12, + byte 33,byte 33,byte 49,byte 49,byte 32,byte 32,byte 77,byte 48, + byte 48,byte 47,byte 47,byte 63,byte 63,byte 46,byte 46,byte 12, + byte 62,byte 62,byte 61,byte 61,byte 61,byte 61,byte 60,byte 60, + byte 60,byte 43,byte 43,byte 59,byte 59,byte 59,byte 42,byte 12, + byte 62,byte 62,byte 61,byte 61,byte 61,byte 44,byte 44,byte 60, + byte 60,byte 43,byte 43,byte 59,byte 59,byte 42,byte 42,byte 12, + byte 45,byte 45,byte 61,byte 61,byte 44,byte 44,byte 44,byte 60, + byte 60,byte 43,byte 43,byte 59,byte 59,byte 42,byte 42,byte 8, + byte 45,byte 45,byte 61,byte 44,byte 44,byte 44,byte 73,byte 60, + byte 43,byte 43,byte 26,byte 72,byte 59,byte 42,byte 42,byte 8, + byte 74,byte 74,byte 57,byte 44,byte 44,byte 73,byte 73,byte 56, + byte 43,byte 43,byte 26,byte 72,byte 72,byte 42,byte 42,byte 8, + byte 58,byte 58,byte 57,byte 57,byte 57,byte 57,byte 56,byte 56, + byte 56,byte 56,byte 39,byte 55,byte 55,byte 55,byte 38,byte 8, + byte 58,byte 58,byte 57,byte 57,byte 57,byte 40,byte 40,byte 56, + byte 56,byte 39,byte 39,byte 55,byte 55,byte 38,byte 38,byte 4, + byte 41,byte 41,byte 40,byte 40,byte 40,byte 40,byte 40,byte 56, + byte 39,byte 39,byte 39,byte 55,byte 55,byte 38,byte 38,byte 4, + byte 41,byte 41,byte 40,byte 40,byte 40,byte 23,byte 23,byte 39, + byte 39,byte 39,byte 22,byte 68,byte 38,byte 38,byte 38,byte 4, + byte 54,byte 54,byte 53,byte 53,byte 53,byte 69,byte 69,byte 52, + byte 52,byte 52,byte 68,byte 68,byte 51,byte 51,byte 21,byte 4, + byte 54,byte 54,byte 53,byte 53,byte 53,byte 53,byte 69,byte 52, + byte 52,byte 52,byte 35,byte 51,byte 51,byte 51,byte 34,byte 0, + byte 37,byte 37,byte 53,byte 36,byte 36,byte 36,byte 36,byte 52, + byte 35,byte 35,byte 35,byte 51,byte 51,byte 34,byte 34,byte 0, + byte 37,byte 37,byte 36,byte 36,byte 36,byte 36,byte 36,byte 35, + byte 35,byte 35,byte 35,byte 18,byte 34,byte 34,byte 34,byte 0, + byte 3,byte 3,byte 3,byte 3,byte 2,byte 2,byte 2,byte 2, + byte 1,byte 1,byte 1,byte 1,byte 0,byte 0,byte 0,byte 0, + byte 16,byte 16,byte 32,byte 32,byte 31,byte 31,byte 31,byte 47, + byte 47,byte 30,byte 30,byte 30,byte 46,byte 46,byte 29,byte 12, + byte 16,byte 16,byte 32,byte 32,byte 31,byte 31,byte 31,byte 47, + byte 47,byte 30,byte 30,byte 30,byte 46,byte 46,byte 29,byte 12, + byte 45,byte 45,byte 44,byte 44,byte 44,byte 44,byte 31,byte 60, + byte 43,byte 43,byte 30,byte 59,byte 59,byte 42,byte 42,byte 12, + byte 45,byte 45,byte 44,byte 44,byte 44,byte 44,byte 27,byte 43, + byte 43,byte 43,byte 26,byte 26,byte 42,byte 42,byte 42,byte 12, + byte 28,byte 28,byte 44,byte 44,byte 27,byte 27,byte 27,byte 43, + byte 43,byte 26,byte 26,byte 26,byte 42,byte 42,byte 25,byte 8, + byte 28,byte 28,byte 44,byte 44,byte 27,byte 27,byte 27,byte 43, + byte 43,byte 26,byte 26,byte 9,byte 42,byte 42,byte 25,byte 8, + byte 28,byte 28,byte 28,byte 27,byte 27,byte 27,byte 10,byte 43, + byte 26,byte 26,byte 26,byte 9,byte 42,byte 42,byte 25,byte 8, + byte 41,byte 41,byte 57,byte 40,byte 40,byte 40,byte 40,byte 56, + byte 39,byte 39,byte 39,byte 55,byte 55,byte 38,byte 38,byte 8, + byte 41,byte 41,byte 40,byte 40,byte 40,byte 40,byte 23,byte 39, + byte 39,byte 39,byte 22,byte 55,byte 38,byte 38,byte 38,byte 4, + byte 24,byte 24,byte 40,byte 40,byte 23,byte 23,byte 23,byte 39, + byte 39,byte 22,byte 22,byte 22,byte 38,byte 38,byte 21,byte 4, + byte 24,byte 24,byte 24,byte 23,byte 23,byte 23,byte 23,byte 39, + byte 22,byte 22,byte 22,byte 5,byte 38,byte 38,byte 21,byte 4, + byte 24,byte 24,byte 53,byte 23,byte 23,byte 6,byte 6,byte 52, + byte 52,byte 22,byte 5,byte 5,byte 51,byte 21,byte 21,byte 4, + byte 37,byte 37,byte 53,byte 36,byte 36,byte 36,byte 36,byte 52, + byte 35,byte 35,byte 35,byte 51,byte 51,byte 34,byte 34,byte 0, + byte 37,byte 37,byte 36,byte 36,byte 36,byte 36,byte 36,byte 35, + byte 35,byte 35,byte 35,byte 18,byte 34,byte 34,byte 34,byte 0, + byte 20,byte 20,byte 36,byte 36,byte 19,byte 19,byte 19,byte 35, + byte 35,byte 18,byte 18,byte 18,byte 34,byte 34,byte 17,byte 0, + byte 3,byte 3,byte 3,byte 3,byte 2,byte 2,byte 2,byte 2, + byte 1,byte 1,byte 1,byte 1,byte 0,byte 0,byte 0,byte 0, + byte 15,byte 15,byte 15,byte 15,byte 14,byte 14,byte 14,byte 14, + byte 13,byte 13,byte 13,byte 13,byte 12,byte 12,byte 12,byte 12, + byte 15,byte 15,byte 15,byte 15,byte 14,byte 14,byte 14,byte 14, + byte 13,byte 13,byte 13,byte 13,byte 12,byte 12,byte 12,byte 12, + byte 15,byte 15,byte 15,byte 15,byte 14,byte 14,byte 14,byte 14, + byte 13,byte 13,byte 13,byte 13,byte 12,byte 12,byte 12,byte 12, + byte 15,byte 15,byte 15,byte 15,byte 14,byte 14,byte 14,byte 14, + byte 13,byte 13,byte 13,byte 13,byte 12,byte 12,byte 12,byte 12, + byte 11,byte 11,byte 11,byte 11,byte 10,byte 10,byte 10,byte 10, + byte 9,byte 9,byte 9,byte 9,byte 8,byte 8,byte 8,byte 8, + byte 11,byte 11,byte 11,byte 11,byte 10,byte 10,byte 10,byte 10, + byte 9,byte 9,byte 9,byte 9,byte 8,byte 8,byte 8,byte 8, + byte 11,byte 11,byte 11,byte 11,byte 10,byte 10,byte 10,byte 10, + byte 9,byte 9,byte 9,byte 9,byte 8,byte 8,byte 8,byte 8, + byte 11,byte 11,byte 11,byte 11,byte 10,byte 10,byte 10,byte 10, + byte 9,byte 9,byte 9,byte 9,byte 8,byte 8,byte 8,byte 8, + byte 7,byte 7,byte 7,byte 7,byte 6,byte 6,byte 6,byte 6, + byte 5,byte 5,byte 5,byte 5,byte 4,byte 4,byte 4,byte 4, + byte 7,byte 7,byte 7,byte 7,byte 6,byte 6,byte 6,byte 6, + byte 5,byte 5,byte 5,byte 5,byte 4,byte 4,byte 4,byte 4, + byte 7,byte 7,byte 7,byte 7,byte 6,byte 6,byte 6,byte 6, + byte 5,byte 5,byte 5,byte 5,byte 4,byte 4,byte 4,byte 4, + byte 7,byte 7,byte 7,byte 7,byte 6,byte 6,byte 6,byte 6, + byte 5,byte 5,byte 5,byte 5,byte 4,byte 4,byte 4,byte 4, + byte 3,byte 3,byte 3,byte 3,byte 2,byte 2,byte 2,byte 2, + byte 1,byte 1,byte 1,byte 1,byte 0,byte 0,byte 0,byte 0, + byte 3,byte 3,byte 3,byte 3,byte 2,byte 2,byte 2,byte 2, + byte 1,byte 1,byte 1,byte 1,byte 0,byte 0,byte 0,byte 0, + byte 3,byte 3,byte 3,byte 3,byte 2,byte 2,byte 2,byte 2, + byte 1,byte 1,byte 1,byte 1,byte 0,byte 0,byte 0,byte 0, + byte 3,byte 3,byte 3,byte 3,byte 2,byte 2,byte 2,byte 2, + byte 1,byte 1,byte 1,byte 1,byte 0,byte 0,byte 0,byte 0, +}; diff --git a/appl/wm/mpeg/decode.b b/appl/wm/mpeg/decode.b new file mode 100644 index 00000000..16906c99 --- /dev/null +++ b/appl/wm/mpeg/decode.b @@ -0,0 +1,831 @@ +implement Mpegd; + +include "sys.m"; +include "mpegio.m"; + +sys: Sys; +idct: IDCT; + +Mpegi, Picture, Slice, MacroBlock, YCbCr, Pair: import Mpegio; + +intra_tab := array[64] of { + 8, 16, 19, 22, 26, 27, 29, 34, + 16, 16, 22, 24, 27, 29, 34, 37, + 19, 22, 26, 27, 29, 34, 34, 38, + 22, 22, 26, 27, 29, 34, 37, 40, + 22, 26, 27, 29, 32, 35, 40, 48, + 26, 27, 29, 32, 35, 40, 48, 58, + 26, 27, 29, 34, 38, 46, 56, 69, + 27, 29, 35, 38, 46, 56, 69, 83, +}; + +nintra_tab := array[64] of { * => 16 }; + +CLOFF: con 256; + +intraQ, nintraQ: array of int; +rtmp: array of array of int; +rflag := array[6] of int; +rforw, dforw, rback, dback: int; +rforw2, dforw2, rback2, dback2: int; +ydb, ydf, cdb, cdf: int; +vflags: int; +past := array[3] of int; +pinit := array[3] of { * => 128 * 8 }; +zeros := array[64] of { * => 0 }; +zeros1: array of int; +clamp := array[CLOFF + 256 + CLOFF] of byte; +width, height, w2, h2: int; +mpi, mps, yadj, cadj, yskip: int; +I, B0: ref YCbCr; +Ps := array[2] of ref YCbCr; +Rs := array[2] of ref YCbCr; +P, B, R, M, N: ref YCbCr; +pn: int = 0; +rn: int = 0; + +zig := array[64] of { + 0, 1, 8, 16, 9, 2, 3, 10, 17, + 24, 32, 25, 18, 11, 4, 5, + 12, 19, 26, 33, 40, 48, 41, 34, + 27, 20, 13, 6, 7, 14, 21, 28, + 35, 42, 49, 56, 57, 50, 43, 36, + 29, 22, 15, 23, 30, 37, 44, 51, + 58, 59, 52, 45, 38, 31, 39, 46, + 53, 60, 61, 54, 47, 55, 62, 63, +}; + +init(m: ref Mpegi) +{ + sys = load Sys Sys->PATH; + idct = load IDCT IDCT->PATH; + if (idct == nil) { + sys->print("could not open %s: %r\n", IDCT->PATH); + exit; + } + idct->init(); + width = m.width; + height = m.height; + w2 = width >> 1; + h2 = height >> 1; + mps = width >> 4; + mpi = mps * height >> 4; + yskip = 8 * width; + yadj = 16 * width - (width - 16); + cadj = 8 * w2 - (w2 - 8); + I = frame(); + Ps[0] = frame(); + Ps[1] = frame(); + Rs[0] = Ps[0]; + Rs[1] = Ps[1]; + B0 = frame(); + for (i := 0; i < CLOFF; i++) + clamp[i] = byte 0; + for (i = 0; i < 256; i++) + clamp[i + CLOFF] = byte i; + for (i = CLOFF + 256; i < CLOFF + 256 + CLOFF; i++) + clamp[i] = byte 255; + if (m.intra == nil) + intraQ = intra_tab; + else + intraQ = zigof(m.intra); + if (m.nintra == nil) + nintraQ = nintra_tab; + else + nintraQ = zigof(m.nintra); + rtmp = array[6] of array of int; + for (i = 0; i < 6; i++) + rtmp[i] = array[64] of int; + zeros1 = zeros[1:]; +} + +zarray(n: int, v: byte): array of byte +{ + return array[n] of { * => v }; +} + +frame(): ref YCbCr +{ + y := zarray(width * height, byte 0); + b := zarray(w2 * h2, byte 128); + r := zarray(w2 * h2, byte 128); + return ref YCbCr(y, b, r); +} + +zigof(a: array of int): array of int +{ + z := array[64] of int; + for (i := 0; i < 64; i++) + z[zig[i]] = a[i]; + return z; +} + +invQ_intra(a: array of Pair, q: int, b: array of int) +{ + (nil, t) := a[0]; + b[0] = t * 8; + b[1:] = zeros1; + n := 1; + i := 1; + while (n < len a) { + (r, l) := a[n++]; + i += r; + x := zig[i++]; + if (l > 0) { + v := l * q * intraQ[x] >> 3; + if (v > 2047) + b[x] = 2047; + else + b[x] = (v - 1) | 1; + } else { + v := (l * q * intraQ[x] + 7) >> 3; + if (v < -2048) + b[x] = -2048; + else + b[x] = v | 1; + } + #sys->print("%d %d %d %d\n", x, r, l, b[x]); + } +} + +invQ_nintra(a: array of Pair, q: int, b: array of int) +{ + b[0:] = zeros; + i := 0; + for (n := 0; n < len a; n++) { + (r, l) := a[n]; + i += r; + if (l == 0) { + raisex("zero level"); + i++; + continue; + } + x := zig[i++]; + if (l > 0) { + v := ((l << 1) + 1) * q * nintraQ[x] >> 4; + if (v > 2047) + b[x] = 2047; + else + b[x] = (v - 1) | 1; + } else { + v := (((l << 1) - 1) * q * nintraQ[x] + 15) >> 4; + if (v < -2048) + b[x] = -2048; + else + b[x] = v | 1; + } + #sys->print("%d %d %d %d\n", x, r, l, b[x]); + } +} + +yzero(v: array of byte, base: int) +{ + x := 0; + i := 8; + do { + n := base; + j := 8; + do + v[n++] = byte 0; + while (--j > 0); + base += width; + } while (--i > 0); +} + +czero(v: array of byte, base: int) +{ + x := 0; + i := 8; + do { + n := base; + j := 8; + do + v[n++] = byte 128; + while (--j > 0); + base += w2; + } while (--i > 0); + +} + +blockzero(d: ref YCbCr) +{ + yzero(d.Y, ybase); + yzero(d.Y, ybase + 8); + yzero(d.Y, ybase + yskip); + yzero(d.Y, ybase + 8 + yskip); + czero(d.Cb, cbase); + czero(d.Cr, cbase); +} + +ydistr(a: array of int, v: array of byte, base: int) +{ + x := 0; + i := 8; + do { + n := base; + j := 8; + do + v[n++] = clamp[a[x++] + CLOFF]; + while (--j > 0); + base += width; + } while (--i > 0); +} + +cdistr(a: array of int, v: array of byte, base: int) +{ + x := 0; + i := 8; + do { + n := base; + j := 8; + do + v[n++] = clamp[a[x++] + CLOFF]; + while (--j > 0); + base += w2; + } while (--i > 0); + +} + +invQ_intra_block(b: array of array of Pair, q: int, pred: int, d: ref YCbCr) +{ + a, dc: array of int; + if (pred) + dc = past; + else + dc = pinit; + p := dc[0]; + for (i := 0; i < 4; i++) { + a = rtmp[i]; + #sys->print("%d\n", i); + invQ_intra(b[i], q, a); + p += a[0]; + a[0] = p; + #sys->print("%d\n", a[0]); + idct->idct(a); + } + past[0] = p; + for (i = 4; i < 6; i++) { + p = dc[i - 3]; + a = rtmp[i]; + #sys->print("%d\n", i); + invQ_intra(b[i], q, a); + p += a[0]; + a[0] = p; + #sys->print("%d\n", a[0]); + past[i - 3] = p; + idct->idct(a); + } + ydistr(rtmp[0], d.Y, ybase); + ydistr(rtmp[1], d.Y, ybase + 8); + ydistr(rtmp[2], d.Y, ybase + yskip); + ydistr(rtmp[3], d.Y, ybase + 8 + yskip); + cdistr(rtmp[4], d.Cb, cbase); + cdistr(rtmp[5], d.Cr, cbase); +} + +invQ_nintra_block(b: array of array of Pair, q: int) +{ + for (i := 0; i < 6; i++) { + p := b[i]; + if (p != nil) { + a := rtmp[i]; + #sys->print("%d\n", i); + invQ_nintra(p, q, a); + idct->idct(a); + rflag[i] = 1; + } else + rflag[i] = 0; + } +} + +mbr, ybase, cbase: int; + +nextmb() +{ + if (--mbr == 0) { + ybase += yadj; + cbase += cadj; + mbr = mps; + } else { + ybase += 16; + cbase += 8; + } +} + +copyblock(s, d: array of byte, b, n, w: int) +{ + i := 8; + do { + d[b:] = s[b:b+n]; + b += w; + } while (--i > 0); +} + +copyblockdisp(s, d: array of byte, b, n, w, p: int) +{ + i := 8; + p += b; + do { + d[b:] = s[p:p+n]; + b += w; + p += w; + } while (--i > 0); +} + +interpblock(s0, s1, d: array of byte, b, n, w, p0, p1: int) +{ + i := 8; + do { + dx := b; + s0x := b + p0; + s1x := b + p1; + j := n; + do + d[dx++] = byte ((int s0[s0x++] + int s1[s1x++] + 1) >> 1); + while (--j > 0); + b += w; + } while (--i > 0); +} + +deltablock(s: array of byte, r: array of int, d: array of byte, b, w, o: int) +{ + rx := 0; + i := 8; + do { + dx := b; + sx := b + o; + j := 8; + do + d[dx++] = clamp[CLOFF + int s[sx++] + r[rx++]]; + while (--j > 0); + b += w; + } while (--i > 0); +} + +deltainterpblock(s0, s1: array of byte, r: array of int, d: array of byte, b, w, o0, o1: int) +{ + rx := 0; + i := 8; + do { + dx := b; + s0x := b + o0; + s1x := b + o1; + j := 8; + do + d[dx++] = clamp[CLOFF + ((int s0[s0x++] + int s1[s1x++] + 1) >> 1) + r[rx++]]; + while (--j > 0); + b += w; + } while (--i > 0); +} + +dispblock(s, d: array of byte, n, b, w, o: int) +{ + if (rflag[n]) + deltablock(s, rtmp[n], d, b, w, o); + else + copyblockdisp(s, d, b, 8, w, o); +} + +genblock(s0, s1, d: array of byte, n, b, w, o0, o1: int) +{ + if (rflag[n]) + deltainterpblock(s0, s1, rtmp[n], d, b, w, o0, o1); + else + interpblock(s0, s1, d, b, 8, w, o0, o1); +} + +copymb() +{ + copyblock(R.Y, P.Y, ybase, 16, width); + copyblock(R.Y, P.Y, ybase + yskip, 16, width); + copyblock(R.Cb, P.Cb, cbase, 8, w2); + copyblock(R.Cr, P.Cr, cbase, 8, w2); +} + +deltamb() +{ + dispblock(R.Y, P.Y, 0, ybase, width, 0); + dispblock(R.Y, P.Y, 1, ybase + 8, width, 0); + dispblock(R.Y, P.Y, 2, ybase + yskip, width, 0); + dispblock(R.Y, P.Y, 3, ybase + 8 + yskip, width, 0); + dispblock(R.Cb, P.Cb, 4, cbase, w2, 0); + dispblock(R.Cr, P.Cr, 5, cbase, w2, 0); +} + +copymbforw() +{ + copyblockdisp(N.Y, B.Y, ybase, 16, width, ydf); + copyblockdisp(N.Y, B.Y, ybase + yskip, 16, width, ydf); + copyblockdisp(N.Cb, B.Cb, cbase, 8, w2, cdf); + copyblockdisp(N.Cr, B.Cr, cbase, 8, w2, cdf); +} + +copymbback() +{ + copyblockdisp(M.Y, B.Y, ybase, 16, width, ydb); + copyblockdisp(M.Y, B.Y, ybase + yskip, 16, width, ydb); + copyblockdisp(M.Cb, B.Cb, cbase, 8, w2, cdb); + copyblockdisp(M.Cr, B.Cr, cbase, 8, w2, cdb); +} + +copymbbackforw() +{ + interpblock(M.Y, N.Y, B.Y, ybase, 16, width, ydb, ydf); + interpblock(M.Y, N.Y, B.Y, ybase + yskip, 16, width, ydb, ydf); + interpblock(M.Cb, N.Cb, B.Cb, cbase, 8, w2, cdb, cdf); + interpblock(M.Cr, N.Cr, B.Cr, cbase, 8, w2, cdb, cdf); +} + +deltambforw() +{ + dispblock(N.Y, B.Y, 0, ybase, width, ydf); + dispblock(N.Y, B.Y, 1, ybase + 8, width, ydf); + dispblock(N.Y, B.Y, 2, ybase + yskip, width, ydf); + dispblock(N.Y, B.Y, 3, ybase + 8 + yskip, width, ydf); + dispblock(N.Cb, B.Cb, 4, cbase, w2, cdf); + dispblock(N.Cr, B.Cr, 5, cbase, w2, cdf); +} + +deltambback() +{ + dispblock(M.Y, B.Y, 0, ybase, width, ydb); + dispblock(M.Y, B.Y, 1, ybase + 8, width, ydb); + dispblock(M.Y, B.Y, 2, ybase + yskip, width, ydb); + dispblock(M.Y, B.Y, 3, ybase + 8 + yskip, width, ydb); + dispblock(M.Cb, B.Cb, 4, cbase, w2, cdb); + dispblock(M.Cr, B.Cr, 5, cbase, w2, cdb); +} + +deltambbackforw() +{ + genblock(M.Y, N.Y, B.Y, 0, ybase, width, ydb, ydf); + genblock(M.Y, N.Y, B.Y, 1, ybase + 8, width, ydb, ydf); + genblock(M.Y, N.Y, B.Y, 2, ybase + yskip, width, ydb, ydf); + genblock(M.Y, N.Y, B.Y, 3, ybase + 8 + yskip, width, ydb, ydf); + genblock(M.Cb, N.Cb, B.Cb, 4, cbase, w2, cdb, cdf); + genblock(M.Cr, N.Cr, B.Cr, 5, cbase, w2, cdb, cdf); +} + +deltambinterp() +{ + case vflags & (Mpegio->MB_MF | Mpegio->MB_MB) { + Mpegio->MB_MF => + deltambforw(); + Mpegio->MB_MB => + deltambback(); + Mpegio->MB_MF | Mpegio->MB_MB => + deltambbackforw(); + * => + raisex("bad vflags"); + } +} + +interpmb() +{ + case vflags & (Mpegio->MB_MF | Mpegio->MB_MB) { + Mpegio->MB_MF => + copymbforw(); + Mpegio->MB_MB => + copymbback(); + Mpegio->MB_MF | Mpegio->MB_MB => + copymbbackforw(); + * => + raisex("bad vflags"); + } +} + +Idecode(p: ref Picture): ref YCbCr +{ + sa := p.slices; + n := 0; + mbr = mps; + ybase = 0; + cbase = 0; + for (i := 0; i < len sa; i++) { + pred := 0; + ba := sa[i].blocks; + for (j := 0; j < len ba; j++) { + invQ_intra_block(ba[j].rls, ba[j].qscale, pred, I); + nextmb(); + n++; + pred = 1; + } + } + if (n != mpi) + raisex("I mb count"); + R = I; + Rs[rn] = I; + rn ^= 1; + return I; +} + +Pdecode(p: ref Picture): ref YCbCr +{ + rforwp, dforwp: int; + md, c: int; + P = Ps[pn]; + N = R; + B = P; + pn ^= 1; + fs := 1 << p.forwfc; + fsr := fs << 5; + fsmin := -(fs << 4); + fsmax := (fs << 4) - 1; + sa := p.slices; + n := 0; + mbr = mps; + ybase = 0; + cbase = 0; + for (i := 0; i < len sa; i++) { + pred := 0; + ipred := 0; + ba := sa[i].blocks; + for (j := 0; j < len ba; j++) { + mb := ba[j]; + while (n < mb.addr) { + copymb(); + ipred = 0; + pred = 0; + nextmb(); + n++; + } + if (mb.flags & Mpegio->MB_I) { + invQ_intra_block(mb.rls, mb.qscale, ipred, P); + #blockzero(P); + ipred = 1; + pred = 0; + } else { + if (mb.flags & Mpegio->MB_MF) { + if (fs == 1 || mb.mhfc == 0) + md = mb.mhfc; + else if ((c = mb.mhfc) < 0) + md = (c + 1) * fs - mb.mhfr - 1; + else + md = (c - 1) * fs + mb.mhfr + 1; + if (pred) + md += rforwp; + if (md > fsmax) + rforw = md - fsr; + else if (md < fsmin) + rforw = md + fsr; + else + rforw = md; + rforwp = rforw; + if (fs == 1 || mb.mvfc == 0) + md = mb.mvfc; + else if ((c = mb.mvfc) < 0) + md = (c + 1) * fs - mb.mvfr - 1; + else + md = (c - 1) * fs + mb.mvfr + 1; + if (pred) + md += dforwp; + if (md > fsmax) + dforw = md - fsr; + else if (md < fsmin) + dforw = md + fsr; + else + dforw = md; + dforwp = dforw; + if (p.flags & Mpegio->FPFV) { + rforw2 = rforw; + dforw2 = dforw; + rforw <<= 1; + dforw <<= 1; + ydf = rforw2 + dforw2 * width; + cdf = (rforw2 >> 1) + (dforw2 >> 1) * w2; + } else { + if (rforw < 0) + rforw2 = (rforw + 1) >> 1; + else + rforw2 = rforw >> 1; + if (dforw < 0) + dforw2 = (dforw + 1) >> 1; + else + dforw2 = dforw >> 1; + ydf = (rforw >> 1) + (dforw >> 1) * width; + cdf = (rforw2 >> 1) + (dforw2 >> 1) * w2; + } + pred = 1; + if (mb.rls != nil) { + invQ_nintra_block(mb.rls, mb.qscale); + deltambforw(); + } else + copymbforw(); + } else { + if (mb.rls == nil) + raisex("empty delta"); + invQ_nintra_block(mb.rls, mb.qscale); + deltamb(); + pred = 0; + } + ipred = 0; + } + nextmb(); + n++; + } + } + while (n < mpi) { + copymb(); + nextmb(); + n++; + } + R = P; + Rs[rn] = P; + rn ^= 1; + return P; +} + +Bdecode(p: ref Mpegio->Picture): ref Mpegio->YCbCr +{ + return Bdecode2(p, Rs[rn ^ 1], Rs[rn]); +} + +Bdecode2(p: ref Mpegio->Picture, f0, f1: ref Mpegio->YCbCr): ref Mpegio->YCbCr +{ + rforwp, dforwp, rbackp, dbackp: int; + md, c: int; + M = f0; + N = f1; + B = B0; + fs := 1 << p.forwfc; + fsr := fs << 5; + fsmin := -(fs << 4); + fsmax := (fs << 4) - 1; + bs := 1 << p.backfc; + bsr := bs << 5; + bsmin := -(bs << 4); + bsmax := (bs << 4) - 1; + sa := p.slices; + n := 0; + mbr = mps; + ybase = 0; + cbase = 0; + for (i := 0; i < len sa; i++) { + ipred := 0; + rback = 0; + rforw = 0; + dback = 0; + dforw = 0; + rbackp = 0; + rforwp = 0; + dbackp = 0; + dforwp = 0; + rback2 = 0; + rforw2 = 0; + dback2 = 0; + dforw2 = 0; + ydb = 0; + ydf = 0; + cdb = 0; + cdf = 0; + ba := sa[i].blocks; + for (j := 0; j < len ba; j++) { + mb := ba[j]; + while (n < mb.addr) { + interpmb(); + nextmb(); + ipred = 0; + n++; + } + if (mb.flags & Mpegio->MB_I) { + invQ_intra_block(mb.rls, mb.qscale, ipred, B); + ipred = 1; + rback = 0; + rforw = 0; + dback = 0; + dforw = 0; + rbackp = 0; + rforwp = 0; + dbackp = 0; + dforwp = 0; + rback2 = 0; + rforw2 = 0; + dback2 = 0; + dforw2 = 0; + ydb = 0; + ydf = 0; + cdb = 0; + cdf = 0; + } else { + if (mb.flags & Mpegio->MB_MF) { + if (fs == 1 || mb.mhfc == 0) + md = mb.mhfc; + else if ((c = mb.mhfc) < 0) + md = (c + 1) * fs - mb.mhfr - 1; + else + md = (c - 1) * fs + mb.mhfr + 1; + md += rforwp; + if (md > fsmax) + rforw = md - fsr; + else if (md < fsmin) + rforw = md + fsr; + else + rforw = md; + rforwp = rforw; + if (fs == 1 || mb.mvfc == 0) + md = mb.mvfc; + else if ((c = mb.mvfc) < 0) + md = (c + 1) * fs - mb.mvfr - 1; + else + md = (c - 1) * fs + mb.mvfr + 1; + md += dforwp; + if (md > fsmax) + dforw = md - fsr; + else if (md < fsmin) + dforw = md + fsr; + else + dforw = md; + dforwp = dforw; + if (p.flags & Mpegio->FPFV) { + rforw2 = rforw; + dforw2 = dforw; + rforw <<= 1; + dforw <<= 1; + ydf = rforw2 + dforw2 * width; + cdf = (rforw2 >> 1) + (dforw2 >> 1) * w2; + } else { + if (rforw < 0) + rforw2 = (rforw + 1) >> 1; + else + rforw2 = rforw >> 1; + if (dforw < 0) + dforw2 = (dforw + 1) >> 1; + else + dforw2 = dforw >> 1; + ydf = (rforw >> 1) + (dforw >> 1) * width; + cdf = (rforw2 >> 1) + (dforw2 >> 1) * w2; + } + } + if (mb.flags & Mpegio->MB_MB) { + if (bs == 1 || mb.mhbc == 0) + md = mb.mhbc; + else if ((c = mb.mhbc) < 0) + md = (c + 1) * bs - mb.mhbr - 1; + else + md = (c - 1) * bs + mb.mhbr + 1; + md += rbackp; + if (md > bsmax) + rback = md - bsr; + else if (md < bsmin) + rback = md + bsr; + else + rback = md; + rbackp = rback; + if (bs == 1 || mb.mvbc == 0) + md = mb.mvbc; + else if ((c = mb.mvbc) < 0) + md = (c + 1) * bs - mb.mvbr - 1; + else + md = (c - 1) * bs + mb.mvbr + 1; + md += dbackp; + if (md > bsmax) + dback = md - bsr; + else if (md < bsmin) + dback = md + bsr; + else + dback = md; + dbackp = dback; + if (p.flags & Mpegio->FPBV) { + rback2 = rback; + dback2 = dback; + rback <<= 1; + dback <<= 1; + ydb = rback2 + dback2 * width; + cdb = (rback2 >> 1) + (dback2 >> 1) * w2; + } else { + if (rback < 0) + rback2 = (rback + 1) >> 1; + else + rback2 = rback >> 1; + if (dback < 0) + dback2 = (dback + 1) >> 1; + else + dback2 = dback >> 1; + ydb = (rback >> 1) + (dback >> 1) * width; + cdb = (rback2 >> 1) + (dback2 >> 1) * w2; + } + } + vflags = mb.flags; + if (mb.rls != nil) { + invQ_nintra_block(mb.rls, mb.qscale); + deltambinterp(); + } else + interpmb(); + ipred = 0; + } + nextmb(); + n++; + } + } + while (n < mpi) { + interpmb(); + nextmb(); + n++; + } + return B; +} + +raisex(nil: string) +{ + raise "decode error"; +} diff --git a/appl/wm/mpeg/decode4.b b/appl/wm/mpeg/decode4.b new file mode 100644 index 00000000..c4a968e8 --- /dev/null +++ b/appl/wm/mpeg/decode4.b @@ -0,0 +1,709 @@ +implement Mpegd; + +include "sys.m"; +include "mpegio.m"; + +sys: Sys; +idct: IDCT; + +Mpegi, Picture, Slice, MacroBlock, YCbCr, Pair: import Mpegio; + +intra_tab := array[64] of { + 8, 16, 19, 22, 26, 27, 29, 34, + 16, 16, 22, 24, 27, 29, 34, 37, + 19, 22, 26, 27, 29, 34, 34, 38, + 22, 22, 26, 27, 29, 34, 37, 40, + 22, 26, 27, 29, 32, 35, 40, 48, + 26, 27, 29, 32, 35, 40, 48, 58, + 26, 27, 29, 34, 38, 46, 56, 69, + 27, 29, 35, 38, 46, 56, 69, 83, +}; + +nintra_tab := array[64] of { * => 16 }; + +CLOFF: con 256; + +intraQ, nintraQ: array of int; +rtmp: array of array of int; +rflag := array[6] of int; +rforw, dforw, rback, dback: int; +ydb, ydf: int; +vflags: int; +past := array[3] of int; +pinit := array[3] of { * => 128 * 8 }; +zeros := array[64] of { * => 0 }; +zeros1: array of int; +clamp := array[CLOFF + 256 + CLOFF] of byte; +width, height, w2, h2: int; +mpi, mps, yadj, yskip: int; +I, B0: ref YCbCr; +Ps := array[2] of ref YCbCr; +Rs := array[2] of ref YCbCr; +P, B, R, M, N: ref YCbCr; +pn: int = 0; +rn: int = 0; + +zig := array[64] of { + 0, 1, 8, 16, 9, 2, 3, 10, 17, + 24, 32, 25, 18, 11, 4, 5, + 12, 19, 26, 33, 40, 48, 41, 34, + 27, 20, 13, 6, 7, 14, 21, 28, + 35, 42, 49, 56, 57, 50, 43, 36, + 29, 22, 15, 23, 30, 37, 44, 51, + 58, 59, 52, 45, 38, 31, 39, 46, + 53, 60, 61, 54, 47, 55, 62, 63, +}; + +init(m: ref Mpegi) +{ + sys = load Sys Sys->PATH; + idct = load IDCT IDCT->SPATH; + if (idct == nil) { + sys->print("could not open %s: %r\n", IDCT->PATH); + exit; + } + idct->init(); + width = m.width; + height = m.height; + w2 = width >> 1; + h2 = height >> 1; + mps = width >> 4; + mpi = mps * height >> 4; + yskip = 8 * width; + yadj = 16 * width - (width - 16); + I = frame(); + Ps[0] = frame(); + Ps[1] = frame(); + Rs[0] = Ps[0]; + Rs[1] = Ps[1]; + B0 = frame(); + for (i := 0; i < CLOFF; i++) + clamp[i] = byte 0; + for (i = 0; i < 256; i++) + clamp[i + CLOFF] = byte i; + for (i = CLOFF + 256; i < CLOFF + 256 + CLOFF; i++) + clamp[i] = byte 255; + if (m.intra == nil) + intraQ = intra_tab; + else + intraQ = zigof(m.intra); + if (m.nintra == nil) + nintraQ = nintra_tab; + else + nintraQ = zigof(m.nintra); + rtmp = array[6] of array of int; + for (i = 0; i < 6; i++) + rtmp[i] = array[64] of int; + zeros1 = zeros[1:]; +} + +zarray(n: int, v: byte): array of byte +{ + return array[n] of { * => v }; +} + +frame(): ref YCbCr +{ + y := zarray(width * height, byte 0); + return ref YCbCr(y, nil, nil); +} + +zigof(a: array of int): array of int +{ + z := array[64] of int; + for (i := 0; i < 64; i++) + z[zig[i]] = a[i]; + return z; +} + +invQ_intra(a: array of Pair, q: int, b: array of int) +{ + (nil, t) := a[0]; + b[0] = t * 8; + b[1:] = zeros1; + n := 1; + i := 1; + while (n < len a) { + (r, l) := a[n++]; + i += r; + x := zig[i++]; + if (l > 0) { + v := l * q * intraQ[x] >> 3; + if (v > 2047) + b[x] = 2047; + else + b[x] = (v - 1) | 1; + } else { + v := (l * q * intraQ[x] + 7) >> 3; + if (v < -2048) + b[x] = -2048; + else + b[x] = v | 1; + } + #sys->print("%d %d %d %d\n", x, r, l, b[x]); + } +} + +invQ_nintra(a: array of Pair, q: int, b: array of int) +{ + b[0:] = zeros; + i := 0; + for (n := 0; n < len a; n++) { + (r, l) := a[n]; + i += r; + if (l == 0) { + raisex("zero level"); + i++; + continue; + } + x := zig[i++]; + if (l > 0) { + v := ((l << 1) + 1) * q * nintraQ[x] >> 4; + if (v > 2047) + b[x] = 2047; + else + b[x] = (v - 1) | 1; + } else { + v := (((l << 1) - 1) * q * nintraQ[x] + 15) >> 4; + if (v < -2048) + b[x] = -2048; + else + b[x] = v | 1; + } + #sys->print("%d %d %d %d\n", x, r, l, b[x]); + } +} + +yzero(v: array of byte, base: int) +{ + x := 0; + i := 8; + do { + n := base; + j := 8; + do + v[n++] = byte 0; + while (--j > 0); + base += width; + } while (--i > 0); +} + +blockzero(d: ref YCbCr) +{ + yzero(d.Y, ybase); + yzero(d.Y, ybase + 8); + yzero(d.Y, ybase + yskip); + yzero(d.Y, ybase + 8 + yskip); +} + +ydistr(a: array of int, v: array of byte, base: int) +{ + x := 0; + i := 8; + do { + n := base; + j := 8; + do + v[n++] = clamp[a[x++] + CLOFF]; + while (--j > 0); + base += width; + } while (--i > 0); +} + +invQ_intra_block(b: array of array of Pair, q: int, pred: int, d: ref YCbCr) +{ + a, dc: array of int; + if (pred) + dc = past; + else + dc = pinit; + p := dc[0]; + for (i := 0; i < 4; i++) { + a = rtmp[i]; + #sys->print("%d\n", i); + invQ_intra(b[i], q, a); + p += a[0]; + a[0] = p; + #sys->print("%d\n", a[0]); + idct->idct(a); + } + past[0] = p; + ydistr(rtmp[0], d.Y, ybase); + ydistr(rtmp[1], d.Y, ybase + 8); + ydistr(rtmp[2], d.Y, ybase + yskip); + ydistr(rtmp[3], d.Y, ybase + 8 + yskip); +} + +invQ_nintra_block(b: array of array of Pair, q: int) +{ + for (i := 0; i < 4; i++) { + p := b[i]; + if (p != nil) { + a := rtmp[i]; + #sys->print("%d\n", i); + invQ_nintra(p, q, a); + idct->idct(a); + rflag[i] = 1; + } else + rflag[i] = 0; + } +} + +mbr, ybase: int; + +nextmb() +{ + if (--mbr == 0) { + ybase += yadj; + mbr = mps; + } else + ybase += 16; +} + +copyblock(s, d: array of byte, b, n, w: int) +{ + i := 8; + do { + d[b:] = s[b:b+n]; + b += w; + } while (--i > 0); +} + +copyblockdisp(s, d: array of byte, b, n, w, p: int) +{ + i := 8; + p += b; + do { + d[b:] = s[p:p+n]; + b += w; + p += w; + } while (--i > 0); +} + +interpblock(s0, s1, d: array of byte, b, n, w, p0, p1: int) +{ + i := 8; + do { + dx := b; + s0x := b + p0; + s1x := b + p1; + j := n; + do + d[dx++] = byte ((int s0[s0x++] + int s1[s1x++] + 1) >> 1); + while (--j > 0); + b += w; + } while (--i > 0); +} + +deltablock(s: array of byte, r: array of int, d: array of byte, b, w, o: int) +{ + rx := 0; + i := 8; + do { + dx := b; + sx := b + o; + j := 8; + do + d[dx++] = clamp[CLOFF + int s[sx++] + r[rx++]]; + while (--j > 0); + b += w; + } while (--i > 0); +} + +deltainterpblock(s0, s1: array of byte, r: array of int, d: array of byte, b, w, o0, o1: int) +{ + rx := 0; + i := 8; + do { + dx := b; + s0x := b + o0; + s1x := b + o1; + j := 8; + do + d[dx++] = clamp[CLOFF + ((int s0[s0x++] + int s1[s1x++] + 1) >> 1) + r[rx++]]; + while (--j > 0); + b += w; + } while (--i > 0); +} + +dispblock(s, d: array of byte, n, b, w, o: int) +{ + if (rflag[n]) + deltablock(s, rtmp[n], d, b, w, o); + else + copyblockdisp(s, d, b, 8, w, o); +} + +genblock(s0, s1, d: array of byte, n, b, w, o0, o1: int) +{ + if (rflag[n]) + deltainterpblock(s0, s1, rtmp[n], d, b, w, o0, o1); + else + interpblock(s0, s1, d, b, 8, w, o0, o1); +} + +copymb() +{ + copyblock(R.Y, P.Y, ybase, 16, width); + copyblock(R.Y, P.Y, ybase + yskip, 16, width); +} + +deltamb() +{ + dispblock(R.Y, P.Y, 0, ybase, width, 0); + dispblock(R.Y, P.Y, 1, ybase + 8, width, 0); + dispblock(R.Y, P.Y, 2, ybase + yskip, width, 0); + dispblock(R.Y, P.Y, 3, ybase + 8 + yskip, width, 0); +} + +copymbforw() +{ + copyblockdisp(N.Y, B.Y, ybase, 16, width, ydf); + copyblockdisp(N.Y, B.Y, ybase + yskip, 16, width, ydf); +} + +copymbback() +{ + copyblockdisp(M.Y, B.Y, ybase, 16, width, ydb); + copyblockdisp(M.Y, B.Y, ybase + yskip, 16, width, ydb); +} + +copymbbackforw() +{ + interpblock(M.Y, N.Y, B.Y, ybase, 16, width, ydb, ydf); + interpblock(M.Y, N.Y, B.Y, ybase + yskip, 16, width, ydb, ydf); +} + +deltambforw() +{ + dispblock(N.Y, B.Y, 0, ybase, width, ydf); + dispblock(N.Y, B.Y, 1, ybase + 8, width, ydf); + dispblock(N.Y, B.Y, 2, ybase + yskip, width, ydf); + dispblock(N.Y, B.Y, 3, ybase + 8 + yskip, width, ydf); +} + +deltambback() +{ + dispblock(M.Y, B.Y, 0, ybase, width, ydb); + dispblock(M.Y, B.Y, 1, ybase + 8, width, ydb); + dispblock(M.Y, B.Y, 2, ybase + yskip, width, ydb); + dispblock(M.Y, B.Y, 3, ybase + 8 + yskip, width, ydb); +} + +deltambbackforw() +{ + genblock(M.Y, N.Y, B.Y, 0, ybase, width, ydb, ydf); + genblock(M.Y, N.Y, B.Y, 1, ybase + 8, width, ydb, ydf); + genblock(M.Y, N.Y, B.Y, 2, ybase + yskip, width, ydb, ydf); + genblock(M.Y, N.Y, B.Y, 3, ybase + 8 + yskip, width, ydb, ydf); +} + +deltambinterp() +{ + case vflags & (Mpegio->MB_MF | Mpegio->MB_MB) { + Mpegio->MB_MF => + deltambforw(); + Mpegio->MB_MB => + deltambback(); + Mpegio->MB_MF | Mpegio->MB_MB => + deltambbackforw(); + * => + raisex("bad vflags"); + } +} + +interpmb() +{ + case vflags & (Mpegio->MB_MF | Mpegio->MB_MB) { + Mpegio->MB_MF => + copymbforw(); + Mpegio->MB_MB => + copymbback(); + Mpegio->MB_MF | Mpegio->MB_MB => + copymbbackforw(); + * => + raisex("bad vflags"); + } +} + +Idecode(p: ref Picture): ref YCbCr +{ + sa := p.slices; + n := 0; + mbr = mps; + ybase = 0; + for (i := 0; i < len sa; i++) { + pred := 0; + ba := sa[i].blocks; + for (j := 0; j < len ba; j++) { + invQ_intra_block(ba[j].rls, ba[j].qscale, pred, I); + nextmb(); + n++; + pred = 1; + } + } + if (n != mpi) + raisex("I mb count"); + R = I; + Rs[rn] = I; + rn ^= 1; + return I; +} + +Pdecode(p: ref Picture): ref YCbCr +{ + rforwp, dforwp: int; + md, c: int; + P = Ps[pn]; + N = R; + B = P; + pn ^= 1; + fs := 1 << p.forwfc; + fsr := fs << 5; + fsmin := -(fs << 4); + fsmax := (fs << 4) - 1; + sa := p.slices; + n := 0; + mbr = mps; + ybase = 0; + for (i := 0; i < len sa; i++) { + pred := 0; + ipred := 0; + ba := sa[i].blocks; + for (j := 0; j < len ba; j++) { + mb := ba[j]; + while (n < mb.addr) { + copymb(); + ipred = 0; + pred = 0; + nextmb(); + n++; + } + if (mb.flags & Mpegio->MB_I) { + invQ_intra_block(mb.rls, mb.qscale, ipred, P); + #blockzero(P); + ipred = 1; + pred = 0; + } else { + if (mb.flags & Mpegio->MB_MF) { + if (fs == 1 || mb.mhfc == 0) + md = mb.mhfc; + else if ((c = mb.mhfc) < 0) + md = (c + 1) * fs - mb.mhfr - 1; + else + md = (c - 1) * fs + mb.mhfr + 1; + if (pred) + md += rforwp; + if (md > fsmax) + rforw = md - fsr; + else if (md < fsmin) + rforw = md + fsr; + else + rforw = md; + rforwp = rforw; + if (fs == 1 || mb.mvfc == 0) + md = mb.mvfc; + else if ((c = mb.mvfc) < 0) + md = (c + 1) * fs - mb.mvfr - 1; + else + md = (c - 1) * fs + mb.mvfr + 1; + if (pred) + md += dforwp; + if (md > fsmax) + dforw = md - fsr; + else if (md < fsmin) + dforw = md + fsr; + else + dforw = md; + dforwp = dforw; + if (p.flags & Mpegio->FPFV) { + ydf = rforw + dforw * width; + rforw <<= 1; + dforw <<= 1; + } else + ydf = (rforw >> 1) + (dforw >> 1) * width; + pred = 1; + if (mb.rls != nil) { + invQ_nintra_block(mb.rls, mb.qscale); + deltambforw(); + } else + copymbforw(); + } else { + if (mb.rls == nil) + raisex("empty delta"); + invQ_nintra_block(mb.rls, mb.qscale); + deltamb(); + pred = 0; + } + ipred = 0; + } + nextmb(); + n++; + } + } + while (n < mpi) { + copymb(); + nextmb(); + n++; + } + R = P; + Rs[rn] = P; + rn ^= 1; + return P; +} + +Bdecode(p: ref Mpegio->Picture): ref Mpegio->YCbCr +{ + return Bdecode2(p, Rs[rn ^ 1], Rs[rn]); +} + +Bdecode2(p: ref Mpegio->Picture, f0, f1: ref Mpegio->YCbCr): ref Mpegio->YCbCr +{ + rforwp, dforwp, rbackp, dbackp: int; + md, c: int; + M = f0; + N = f1; + B = B0; + fs := 1 << p.forwfc; + fsr := fs << 5; + fsmin := -(fs << 4); + fsmax := (fs << 4) - 1; + bs := 1 << p.backfc; + bsr := bs << 5; + bsmin := -(bs << 4); + bsmax := (bs << 4) - 1; + sa := p.slices; + n := 0; + mbr = mps; + ybase = 0; + for (i := 0; i < len sa; i++) { + ipred := 0; + rback = 0; + rforw = 0; + dback = 0; + dforw = 0; + rbackp = 0; + rforwp = 0; + dbackp = 0; + dforwp = 0; + ydb = 0; + ydf = 0; + ba := sa[i].blocks; + for (j := 0; j < len ba; j++) { + mb := ba[j]; + while (n < mb.addr) { + interpmb(); + nextmb(); + ipred = 0; + n++; + } + if (mb.flags & Mpegio->MB_I) { + invQ_intra_block(mb.rls, mb.qscale, ipred, B); + ipred = 1; + rback = 0; + rforw = 0; + dback = 0; + dforw = 0; + rbackp = 0; + rforwp = 0; + dbackp = 0; + dforwp = 0; + ydb = 0; + ydf = 0; + } else { + if (mb.flags & Mpegio->MB_MF) { + if (fs == 1 || mb.mhfc == 0) + md = mb.mhfc; + else if ((c = mb.mhfc) < 0) + md = (c + 1) * fs - mb.mhfr - 1; + else + md = (c - 1) * fs + mb.mhfr + 1; + md += rforwp; + if (md > fsmax) + rforw = md - fsr; + else if (md < fsmin) + rforw = md + fsr; + else + rforw = md; + rforwp = rforw; + if (fs == 1 || mb.mvfc == 0) + md = mb.mvfc; + else if ((c = mb.mvfc) < 0) + md = (c + 1) * fs - mb.mvfr - 1; + else + md = (c - 1) * fs + mb.mvfr + 1; + md += dforwp; + if (md > fsmax) + dforw = md - fsr; + else if (md < fsmin) + dforw = md + fsr; + else + dforw = md; + dforwp = dforw; + if (p.flags & Mpegio->FPFV) { + ydf = rforw + dforw * width; + rforw <<= 1; + dforw <<= 1; + } else + ydf = (rforw >> 1) + (dforw >> 1) * width; + } + if (mb.flags & Mpegio->MB_MB) { + if (bs == 1 || mb.mhbc == 0) + md = mb.mhbc; + else if ((c = mb.mhbc) < 0) + md = (c + 1) * bs - mb.mhbr - 1; + else + md = (c - 1) * bs + mb.mhbr + 1; + md += rbackp; + if (md > bsmax) + rback = md - bsr; + else if (md < bsmin) + rback = md + bsr; + else + rback = md; + rbackp = rback; + if (bs == 1 || mb.mvbc == 0) + md = mb.mvbc; + else if ((c = mb.mvbc) < 0) + md = (c + 1) * bs - mb.mvbr - 1; + else + md = (c - 1) * bs + mb.mvbr + 1; + md += dbackp; + if (md > bsmax) + dback = md - bsr; + else if (md < bsmin) + dback = md + bsr; + else + dback = md; + dbackp = dback; + if (p.flags & Mpegio->FPBV) { + ydb = rback + dback * width; + rback <<= 1; + dback <<= 1; + } else + ydb = (rback >> 1) + (dback >> 1) * width; + } + vflags = mb.flags; + if (mb.rls != nil) { + invQ_nintra_block(mb.rls, mb.qscale); + deltambinterp(); + } else + interpmb(); + ipred = 0; + } + nextmb(); + n++; + } + } + while (n < mpi) { + interpmb(); + nextmb(); + n++; + } + return B; +} + +raisex(nil: string) +{ + raise "decode error"; +} diff --git a/appl/wm/mpeg/fixidct.b b/appl/wm/mpeg/fixidct.b new file mode 100644 index 00000000..992cf837 --- /dev/null +++ b/appl/wm/mpeg/fixidct.b @@ -0,0 +1,188 @@ +implement IDCT; + +include "sys.m"; +include "mpegio.m"; + +init() +{ +} + +# IDCT based on Arai, Agui, and Nakajima, using flow chart Figure 4.8 +# of Pennebaker & Mitchell, JPEG: Still Image Data Compression Standard. +# Remember IDCT is reverse of flow of DCT. +# Nasty truncated integer version (not compliant). + +B0: con 16; +B1: con 16; +M: con (1 << B0); +N: con (1 << B1); + +a0: con 1.414; +a1: con 0.707; +a2: con 0.541; +a3: con 0.707; +a4: con 1.307; +a5: con -0.383; + +A0: con int (a0 * real N); +A1: con int (a1 * real M); +A2: con int (a2 * real M); +A3: con int (a3 * real M); +A4: con int (a4 * real M); +A5: con int (a5 * real M); + +# scaling factors from eqn 4-35 of P&M +s1: con 1.0196; +s2: con 1.0823; +s3: con 1.2026; +s4: con 1.4142; +s5: con 1.8000; +s6: con 2.6131; +s7: con 5.1258; + +S1: con int (s1 * real N); +S2: con int (s2 * real N); +S3: con int (s3 * real N); +S4: con int (s4 * real N); +S5: con int (s5 * real N); +S6: con int (s6 * real N); +S7: con int (s7 * real N); + +# overall normalization of 1/16, folded into premultiplication on vertical pass +S: con 4; +scale: con 0.0625; + +idct(b: array of int) +{ + x, y: int; + + r := array[8*8] of int; + + # transform horizontally + for(y=0; y<8; y++){ + eighty := y<<3; + # if all non-DC components are zero, just propagate the DC term + if(b[eighty+1]==0) + if(b[eighty+2]==0 && b[eighty+3]==0) + if(b[eighty+4]==0 && b[eighty+5]==0) + if(b[eighty+6]==0 && b[eighty+7]==0){ + v := b[eighty]*A0; + r[eighty+0] = v; + r[eighty+1] = v; + r[eighty+2] = v; + r[eighty+3] = v; + r[eighty+4] = v; + r[eighty+5] = v; + r[eighty+6] = v; + r[eighty+7] = v; + continue; + } + + # step 5 + in1 := S1*b[eighty+1]; + in3 := S3*b[eighty+3]; + in5 := S5*b[eighty+5]; + in7 := S7*b[eighty+7]; + f2 := S2*b[eighty+2]; + f3 := S6*b[eighty+6]; + f5 := (in1+in7); + f7 := (in5+in3); + + # step 4 + g2 := f2-f3; + g4 := (in5-in3); + g6 := (in1-in7); + g7 := f5+f7; + + # step 3.5 + t := ((g4+g6)>>B0)*A5; + + # step 3 + f0 := A0*b[eighty+0]; + f1 := S4*b[eighty+4]; + f3 += f2; + f2 = A1*(g2>>B0); + + # step 2 + g0 := f0+f1; + g1 := f0-f1; + g3 := f2+f3; + g4 = t-A2*(g4>>B0); + g5 := A3*((f5-f7)>>B0); + g6 = A4*(g6>>B0)+t; + + # step 1 + f0 = g0+g3; + f1 = g1+f2; + f2 = g1-f2; + f3 = g0-g3; + f5 = g5-g4; + f6 := g5+g6; + f7 = g6+g7; + + # step 6 + r[eighty+0] = (f0+f7); + r[eighty+1] = (f1+f6); + r[eighty+2] = (f2+f5); + r[eighty+3] = (f3-g4); + r[eighty+4] = (f3+g4); + r[eighty+5] = (f2-f5); + r[eighty+6] = (f1-f6); + r[eighty+7] = (f0-f7); + } + + # transform vertically + for(x=0; x<8; x++){ + # step 5 + in1 := S1*(r[x+8]>>(B1+S)); + in3 := S3*(r[x+24]>>(B1+S)); + in5 := S5*(r[x+40]>>(B1+S)); + in7 := S7*(r[x+56]>>(B1+S)); + f2 := S2*(r[x+16]>>(B1+S)); + f3 := S6*(r[x+48]>>(B1+S)); + f5 := (in1+in7); + f7 := (in5+in3); + + # step 4 + g2 := f2-f3; + g4 := (in5-in3); + g6 := (in1-in7); + g7 := f5+f7; + + # step 3.5 + t := ((g4+g6)>>B0)*A5; + + # step 3 + f0 := A0*(r[x]>>(B1+S)); + f1 := S4*(r[x+32]>>(B1+S)); + f3 += f2; + f2 = A1*(g2>>B0); + + # step 2 + g0 := f0+f1; + g1 := f0-f1; + g3 := f2+f3; + g4 = t-A2*(g4>>B0); + g5 := A3*((f5-f7)>>B0); + g6 = A4*(g6>>B0)+t; + + # step 1 + f0 = g0+g3; + f1 = g1+f2; + f2 = g1-f2; + f3 = g0-g3; + f5 = g5-g4; + f6 := g5+g6; + f7 = g6+g7; + + # step 6 + b[x] = (f0+f7)>>B1; + b[x+8] = (f1+f6)>>B1; + b[x+16] = (f2+f5)>>B1; + b[x+24] = (f3-g4)>>B1; + b[x+32] = (f3+g4)>>B1; + b[x+40] = (f2-f5)>>B1; + b[x+48] = (f1-f6)>>B1; + b[x+56] = (f0-f7)>>B1; + } +} diff --git a/appl/wm/mpeg/fltidct.b b/appl/wm/mpeg/fltidct.b new file mode 100644 index 00000000..24c80fe2 --- /dev/null +++ b/appl/wm/mpeg/fltidct.b @@ -0,0 +1,177 @@ +implement IDCT; + +include "sys.m"; +include "mpegio.m"; + +init() +{ +} + +# IDCT based on Arai, Agui, and Nakajima, using flow chart Figure 4.8 +# of Pennebaker & Mitchell, JPEG: Still Image Data Compression Standard. +# Remember IDCT is reverse of flow of DCT. +# Based on rob's readjpeg.b + +a0: con 1.414; +a1: con 0.707; +a2: con 0.541; +a3: con 0.707; +a4: con 1.307; +a5: con -0.383; + +# scaling factors from eqn 4-35 of P&M +s1: con 1.0196; +s2: con 1.0823; +s3: con 1.2026; +s4: con 1.4142; +s5: con 1.8000; +s6: con 2.6131; +s7: con 5.1258; + +# overall normalization of 1/16, folded into premultiplication on vertical pass +scale: con 0.0625; + +ridct(zin: array of real, zout: array of real) +{ + x, y: int; + + r := array[8*8] of real; + + # transform horizontally + for(y=0; y<8; y++){ + eighty := y<<3; + # if all non-DC components are zero, just propagate the DC term + if(zin[eighty+1]==0.) + if(zin[eighty+2]==0. && zin[eighty+3]==0.) + if(zin[eighty+4]==0. && zin[eighty+5]==0.) + if(zin[eighty+6]==0. && zin[eighty+7]==0.){ + v := zin[eighty]*a0; + r[eighty+0] = v; + r[eighty+1] = v; + r[eighty+2] = v; + r[eighty+3] = v; + r[eighty+4] = v; + r[eighty+5] = v; + r[eighty+6] = v; + r[eighty+7] = v; + continue; + } + + # step 5 + in1 := s1*zin[eighty+1]; + in3 := s3*zin[eighty+3]; + in5 := s5*zin[eighty+5]; + in7 := s7*zin[eighty+7]; + f2 := s2*zin[eighty+2]; + f3 := s6*zin[eighty+6]; + f5 := (in1+in7); + f7 := (in5+in3); + + # step 4 + g2 := f2-f3; + g4 := (in5-in3); + g6 := (in1-in7); + g7 := f5+f7; + + # step 3.5 + t := (g4+g6)*a5; + + # step 3 + f0 := a0*zin[eighty+0]; + f1 := s4*zin[eighty+4]; + f3 += f2; + f2 = a1*g2; + + # step 2 + g0 := f0+f1; + g1 := f0-f1; + g3 := f2+f3; + g4 = t-a2*g4; + g5 := a3*(f5-f7); + g6 = a4*g6+t; + + # step 1 + f0 = g0+g3; + f1 = g1+f2; + f2 = g1-f2; + f3 = g0-g3; + f5 = g5-g4; + f6 := g5+g6; + f7 = g6+g7; + + # step 6 + r[eighty+0] = (f0+f7); + r[eighty+1] = (f1+f6); + r[eighty+2] = (f2+f5); + r[eighty+3] = (f3-g4); + r[eighty+4] = (f3+g4); + r[eighty+5] = (f2-f5); + r[eighty+6] = (f1-f6); + r[eighty+7] = (f0-f7); + } + + # transform vertically + for(x=0; x<8; x++){ + # step 5 + in1 := scale*s1*r[x+8]; + in3 := scale*s3*r[x+24]; + in5 := scale*s5*r[x+40]; + in7 := scale*s7*r[x+56]; + f2 := scale*s2*r[x+16]; + f3 := scale*s6*r[x+48]; + f5 := (in1+in7); + f7 := (in5+in3); + + # step 4 + g2 := f2-f3; + g4 := (in5-in3); + g6 := (in1-in7); + g7 := f5+f7; + + # step 3.5 + t := (g4+g6)*a5; + + # step 3 + f0 := scale*a0*r[x]; + f1 := scale*s4*r[x+32]; + f3 += f2; + f2 = a1*g2; + + # step 2 + g0 := f0+f1; + g1 := f0-f1; + g3 := f2+f3; + g4 = t-a2*g4; + g5 := a3*(f5-f7); + g6 = a4*g6+t; + + # step 1 + f0 = g0+g3; + f1 = g1+f2; + f2 = g1-f2; + f3 = g0-g3; + f5 = g5-g4; + f6 := g5+g6; + f7 = g6+g7; + + # step 6 + zout[x] = (f0+f7); + zout[x+8] = (f1+f6); + zout[x+16] = (f2+f5); + zout[x+24] = (f3-g4); + zout[x+32] = (f3+g4); + zout[x+40] = (f2-f5); + zout[x+48] = (f1-f6); + zout[x+56] = (f0-f7); + } +} + +idct(b: array of int) +{ + tmp := array[64] of real; + for (i := 0; i < 64; i++) + tmp[i] = real b[i]; + ridct(tmp, tmp); + for (i = 0; i < 64; i++) + b[i] = int tmp[i]; +} diff --git a/appl/wm/mpeg/mai.tab b/appl/wm/mpeg/mai.tab new file mode 100644 index 00000000..8884adad --- /dev/null +++ b/appl/wm/mpeg/mai.tab @@ -0,0 +1,2053 @@ +# vlc mai +mai_size: con 2048; +mai_bits: con 11; +mai_table:= array[] of { + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (11, 33), + (11, 32), + (11, 31), + (11, 30), + (11, 29), + (11, 28), + (11, 27), + (11, 26), + (11, 25), + (11, 24), + (11, 23), + (11, 22), + (10, 21), + (10, 21), + (10, 20), + (10, 20), + (10, 19), + (10, 19), + (10, 18), + (10, 18), + (10, 17), + (10, 17), + (10, 16), + (10, 16), + (8, 15), + (8, 15), + (8, 15), + (8, 15), + (8, 15), + (8, 15), + (8, 15), + (8, 15), + (8, 14), + (8, 14), + (8, 14), + (8, 14), + (8, 14), + (8, 14), + (8, 14), + (8, 14), + (8, 13), + (8, 13), + (8, 13), + (8, 13), + (8, 13), + (8, 13), + (8, 13), + (8, 13), + (8, 12), + (8, 12), + (8, 12), + (8, 12), + (8, 12), + (8, 12), + (8, 12), + (8, 12), + (8, 11), + (8, 11), + (8, 11), + (8, 11), + (8, 11), + (8, 11), + (8, 11), + (8, 11), + (8, 10), + (8, 10), + (8, 10), + (8, 10), + (8, 10), + (8, 10), + (8, 10), + (8, 10), + (7, 9), + (7, 9), + (7, 9), + (7, 9), + (7, 9), + (7, 9), + (7, 9), + (7, 9), + (7, 9), + (7, 9), + (7, 9), + (7, 9), + (7, 9), + (7, 9), + (7, 9), + (7, 9), + (7, 8), + (7, 8), + (7, 8), + (7, 8), + (7, 8), + (7, 8), + (7, 8), + (7, 8), + (7, 8), + (7, 8), + (7, 8), + (7, 8), + (7, 8), + (7, 8), + (7, 8), + (7, 8), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 7), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (4, 4), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (3, 2), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), + (1, 1), +}; diff --git a/appl/wm/mpeg/mai.vlc b/appl/wm/mpeg/mai.vlc new file mode 100644 index 00000000..108c4658 --- /dev/null +++ b/appl/wm/mpeg/mai.vlc @@ -0,0 +1,35 @@ +# Macroblock Address Increment +# vlc mai < mai.vlc > mai.tab +1 1 +011 2 +010 3 +0011 4 +0010 5 +00011 6 +00010 7 +0000111 8 +0000110 9 +00001011 10 +00001010 11 +00001001 12 +00001000 13 +00000111 14 +00000110 15 +0000010111 16 +0000010110 17 +0000010101 18 +0000010100 19 +0000010011 20 +0000010010 21 +00000100011 22 +00000100010 23 +00000100001 24 +00000100000 25 +00000011111 26 +00000011110 27 +00000011101 28 +00000011100 29 +00000011011 30 +00000011010 31 +00000011001 32 +00000011000 33 diff --git a/appl/wm/mpeg/makergbvmap.b b/appl/wm/mpeg/makergbvmap.b new file mode 100644 index 00000000..9e7e7ffa --- /dev/null +++ b/appl/wm/mpeg/makergbvmap.b @@ -0,0 +1,31 @@ +implement MakeRGBVMap; + +include "sys.m"; +include "draw.m"; + +draw: Draw; +sys: Sys; + +Display: import draw; + +MakeRGBVMap: module +{ + init: fn(ctxt: ref Draw->Context, nil: list of string); +}; + +init(ctxt: ref Draw->Context, nil: list of string) +{ + sys = load Sys Sys->PATH; + draw = load Draw Draw->PATH; + if (draw == nil) { + sys->print("could not load %s: %r\n", Draw->PATH); + exit; + } + d := ctxt.display; + sys->print("rgbvmap := array[3*256] of {\n"); + for (i := 0; i < 256; i++) { + (r, g, b) := d.cmap2rgb(i); + sys->print("\tbyte\t%d,byte\t%d,byte\t%d,\n", r, g, b); + } + sys->print("};\n"); +} diff --git a/appl/wm/mpeg/maketables b/appl/wm/mpeg/maketables new file mode 100644 index 00000000..d663a36e --- /dev/null +++ b/appl/wm/mpeg/maketables @@ -0,0 +1,36 @@ +echo motion: +vlc motion < motion.vlc > motion.tab +echo rl0f: +vlc -c rl0f < rl0f.vlc > rl0f.tab +echo rl0n: +vlc -c rl0n < rl0n.vlc > rl0n.tab +echo c0: +vlc -uUNDEF,UNDEF c0 < c0.vlc > c0.tab +echo c1: +vlc -cfp c1 < c1.vlc > c1.tab +echo c2: +vlc -cfp c2 < c2.vlc > c2.tab +echo c3: +vlc -cfp c3 < c3.vlc > c3.tab +echo c4: +vlc -cfp c4 < c4.vlc > c4.tab +echo c5: +vlc -cfp c5 < c5.vlc > c5.tab +echo c6: +vlc -cfp c6 < c6.vlc > c6.tab +echo c7: +vlc -cfp c7 < c7.vlc > c7.tab +echo mai: +vlc mai < mai.vlc > mai.tab +echo mbi: +vlc mbi < mbi.vlc > mbi.tab +echo mbp: +vlc mbp < mbp.vlc > mbp.tab +echo mbb: +vlc mbb < mbb.vlc > mbb.tab +echo cbp: +vlc cbp < cbp.vlc > cbp.tab +echo cdc: +vlc cdc < cdc.vlc > cdc.tab +echo ydc: +vlc ydc < ydc.vlc > ydc.tab diff --git a/appl/wm/mpeg/mbb.tab b/appl/wm/mpeg/mbb.tab new file mode 100644 index 00000000..4707d394 --- /dev/null +++ b/appl/wm/mpeg/mbb.tab @@ -0,0 +1,69 @@ +# vlc mbb +mbb_size: con 64; +mbb_bits: con 6; +mbb_table:= array[] of { + (0, UNDEF), + (6, 10), + (6, 6), + (6, 4), + (5, 8), + (5, 8), + (5, 9), + (5, 9), + (4, 0), + (4, 0), + (4, 0), + (4, 0), + (4, 3), + (4, 3), + (4, 3), + (4, 3), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 5), + (3, 5), + (3, 5), + (3, 5), + (3, 5), + (3, 5), + (3, 5), + (3, 5), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 7), + (2, 7), + (2, 7), + (2, 7), + (2, 7), + (2, 7), + (2, 7), + (2, 7), + (2, 7), + (2, 7), + (2, 7), + (2, 7), + (2, 7), + (2, 7), + (2, 7), + (2, 7), +}; diff --git a/appl/wm/mpeg/mbb.vlc b/appl/wm/mpeg/mbb.vlc new file mode 100644 index 00000000..1cc57796 --- /dev/null +++ b/appl/wm/mpeg/mbb.vlc @@ -0,0 +1,13 @@ +# Macroblock Type-B +# vlc mbb < mbb.vlc > mbb.tab +0010 0 +010 1 +10 2 +0011 3 +000011 4 +011 5 +000010 6 +11 7 +00010 8 +00011 9 +000001 10 diff --git a/appl/wm/mpeg/mbi.tab b/appl/wm/mpeg/mbi.tab new file mode 100644 index 00000000..7a72eb3f --- /dev/null +++ b/appl/wm/mpeg/mbi.tab @@ -0,0 +1,9 @@ +# vlc mbi +mbi_size: con 4; +mbi_bits: con 2; +mbi_table:= array[] of { + (0, UNDEF), + (2, 1), + (1, 0), + (1, 0), +}; diff --git a/appl/wm/mpeg/mbi.vlc b/appl/wm/mpeg/mbi.vlc new file mode 100644 index 00000000..4b4349bc --- /dev/null +++ b/appl/wm/mpeg/mbi.vlc @@ -0,0 +1,4 @@ +# Macroblock Type-I +# vlc mbi < mbi.vlc > mbi.tab +1 0 +01 1 diff --git a/appl/wm/mpeg/mbp.tab b/appl/wm/mpeg/mbp.tab new file mode 100644 index 00000000..26b41fec --- /dev/null +++ b/appl/wm/mpeg/mbp.tab @@ -0,0 +1,69 @@ +# vlc mbp +mbp_size: con 64; +mbp_bits: con 6; +mbp_table:= array[] of { + (0, UNDEF), + (6, 6), + (5, 2), + (5, 2), + (5, 4), + (5, 4), + (5, 5), + (5, 5), + (3, 0), + (3, 0), + (3, 0), + (3, 0), + (3, 0), + (3, 0), + (3, 0), + (3, 0), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), + (1, 3), +}; diff --git a/appl/wm/mpeg/mbp.vlc b/appl/wm/mpeg/mbp.vlc new file mode 100644 index 00000000..8893ff9b --- /dev/null +++ b/appl/wm/mpeg/mbp.vlc @@ -0,0 +1,9 @@ +# Macroblock Type-P +# vlc mbp < mbp.vlc > mbp.tab +001 0 +01 1 +00001 2 +1 3 +00010 4 +00011 5 +000001 6 diff --git a/appl/wm/mpeg/mkfile b/appl/wm/mpeg/mkfile new file mode 100644 index 00000000..1b23f370 --- /dev/null +++ b/appl/wm/mpeg/mkfile @@ -0,0 +1,47 @@ +<../../../mkconfig + +TARG=\ + decode.dis\ + decode4.dis\ + fixidct.dis\ + fltidct.dis\ + makergbvmap.dis\ + mpegio.dis\ + refidct.dis\ + remap.dis\ + remap1.dis\ + remap2.dis\ + remap4.dis\ + remap24.dis\ + remap8.dis\ + scidct.dis\ + vlc.dis\ + +MODULES=\ + closest.m\ + mpegio.m\ + rgbvmap.m\ + +SYSMODULES=\ + bufio.m\ + draw.m\ + math.m\ + sys.m\ + tk.m\ + wmlib.m\ + +DISBIN=$ROOT/dis/mpeg + +<$ROOT/mkfiles/mkdis + +all:V: mpeg.dis + +install:V: $ROOT/dis/mpeg/mpeg.dis + +$ROOT/dis/mpeg/mpeg.dis: mpeg.dis + rm -f $target && cp mpeg.dis $target + +mpeg.dis: $MODULES $SYS_MODULE + +nuke:V: + rm -f $ROOT/dis/mpeg/mpeg.dis diff --git a/appl/wm/mpeg/motion.tab b/appl/wm/mpeg/motion.tab new file mode 100644 index 00000000..ca619976 --- /dev/null +++ b/appl/wm/mpeg/motion.tab @@ -0,0 +1,2053 @@ +# vlc motion +motion_size: con 2048; +motion_bits: con 11; +motion_table:= array[] of { + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (0, UNDEF), + (11, 16), + (11, -16), + (11, 15), + (11, -15), + (11, 14), + (11, -14), + (11, 13), + (11, -13), + (11, 12), + (11, -12), + (11, 11), + (11, -11), + (10, 10), + (10, 10), + (10, -10), + (10, -10), + (10, 9), + (10, 9), + (10, -9), + (10, -9), + (10, 8), + (10, 8), + (10, -8), + (10, -8), + (8, 7), + (8, 7), + (8, 7), + (8, 7), + (8, 7), + (8, 7), + (8, 7), + (8, 7), + (8, -7), + (8, -7), + (8, -7), + (8, -7), + (8, -7), + (8, -7), + (8, -7), + (8, -7), + (8, 6), + (8, 6), + (8, 6), + (8, 6), + (8, 6), + (8, 6), + (8, 6), + (8, 6), + (8, -6), + (8, -6), + (8, -6), + (8, -6), + (8, -6), + (8, -6), + (8, -6), + (8, -6), + (8, 5), + (8, 5), + (8, 5), + (8, 5), + (8, 5), + (8, 5), + (8, 5), + (8, 5), + (8, -5), + (8, -5), + (8, -5), + (8, -5), + (8, -5), + (8, -5), + (8, -5), + (8, -5), + (7, 4), + (7, 4), + (7, 4), + (7, 4), + (7, 4), + (7, 4), + (7, 4), + (7, 4), + (7, 4), + (7, 4), + (7, 4), + (7, 4), + (7, 4), + (7, 4), + (7, 4), + (7, 4), + (7, -4), + (7, -4), + (7, -4), + (7, -4), + (7, -4), + (7, -4), + (7, -4), + (7, -4), + (7, -4), + (7, -4), + (7, -4), + (7, -4), + (7, -4), + (7, -4), + (7, -4), + (7, -4), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, 3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (5, -3), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, 2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (4, -2), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, 1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (3, -1), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), + (1, 0), +}; diff --git a/appl/wm/mpeg/motion.vlc b/appl/wm/mpeg/motion.vlc new file mode 100644 index 00000000..db98581e --- /dev/null +++ b/appl/wm/mpeg/motion.vlc @@ -0,0 +1,19 @@ +# Motion Codes +# vlc motion < motion.vlc > motion.tab +1 0 +01s 1 +001s 2 +0001s 3 +000011s 4 +0000101s 5 +0000100s 6 +0000011s 7 +000001011s 8 +000001010s 9 +000001001s 10 +0000010001s 11 +0000010000s 12 +0000001111s 13 +0000001110s 14 +0000001101s 15 +0000001100s 16 diff --git a/appl/wm/mpeg/mpeg.b b/appl/wm/mpeg/mpeg.b new file mode 100644 index 00000000..1ac8c276 --- /dev/null +++ b/appl/wm/mpeg/mpeg.b @@ -0,0 +1,285 @@ +implement WmMpeg; + +include "sys.m"; + sys: Sys; + +include "draw.m"; + draw: Draw; + Point, Rect, Display, Image: import draw; + +include "tk.m"; + tk: Tk; + Toplevel: import tk; + +include "tkclient.m"; + tkclient: Tkclient; + ctxt: ref Draw->Context; + +include "dialog.m"; + dialog: Dialog; + +include "selectfile.m"; + selectfile: Selectfile; + +include "mpegio.m"; + +include "arg.m"; + +mio: Mpegio; +decode: Mpegd; +remap: Remap; +Mpegi: import mio; + +WmMpeg: module +{ + init: fn(ctxt: ref Draw->Context, argv: list of string); +}; + +Stopped, Playing, Stepping, Paused: con iota; +state := Stopped; +depth := -1; +sdepth: int; +cvt: ref Image; + +pixelrec: Draw->Rect; + +decoders := array[] of { +1=> Mpegd->PATH4, +2=> Mpegd->PATH4, +4=> Mpegd->PATH4, +8 or 16 or 24 or 32 => Mpegd->PATH, +}; + +remappers := array[] of { +1=> Remap->PATH1, +2=> Remap->PATH2, +4=> Remap->PATH4, +8 or 16 or 24 or 32 => Remap->PATH, +}; + +task_cfg := array[] of { + "canvas .c", + "frame .b", + "button .b.File -text File -command {send cmd file}", + "button .b.Stop -text Stop -command {send cmd stop}", + "button .b.Pause -text Pause -command {send cmd pause}", + "button .b.Step -text Step -command {send cmd step}", + "button .b.Play -text Play -command {send cmd play}", + "frame .f", + "label .f.file -text {File:}", + "label .f.name", + "pack .f.file .f.name -side left", + "pack .b.File .b.Stop .b.Pause .b.Step .b.Play -side left", + "pack .f -fill x", + "pack .b -anchor w", + "pack .c -side bottom -fill both -expand 1", + "pack propagate . 0", +}; + +init(xctxt: ref Draw->Context, argv: list of string) +{ + sys = load Sys Sys->PATH; + draw = load Draw Draw->PATH; + tk = load Tk Tk->PATH; + tkclient= load Tkclient Tkclient->PATH; + dialog = load Dialog Dialog->PATH; + selectfile= load Selectfile Selectfile->PATH; + + ctxt = xctxt; + tkclient->init(); + dialog->init(); + selectfile->init(); + + darg, tkarg: string; + arg := load Arg Arg->PATH; + arg->init(argv); + while((c := arg->opt()) != 0) + case c { + 'x' => + tkarg = arg->arg(); + 'd' => + darg = arg->arg(); + } + args := arg->argv(); + arg = nil; + if(darg != nil) + depth = int darg; + sdepth = ctxt.display.image.depth; + if (depth < 0 || depth > sdepth) + depth = sdepth; + (t, menubut) := tkclient->toplevel(ctxt, tkarg, "MPEG Player", 0); + + cmd := chan of string; + tk->namechan(t, cmd, "cmd"); + + for(i:=0; i<len task_cfg; i++) + tk->cmd(t, task_cfg[i]); + + tk->cmd(t, "bind . <Configure> {send cmd resize}"); + tk->cmd(t, "update"); + tkclient->onscreen(t, nil); + tkclient->startinput(t, "kbd"::"ptr"::nil); + + mio = load Mpegio Mpegio->PATH; + decode = load Mpegd decoders[depth]; + remap = load Remap remappers[depth]; + if(mio == nil || decode == nil || remap == nil) { + dialog->prompt(ctxt, t.image, "error -fg red", "Loading Interfaces", + "Failed to load the MPEG\ninterface: "+sys->sprint("%r"), + 0, "Exit"::nil); + return; + } + mio->init(); + + fname := ""; + ctl := chan of string; + state = Stopped; + + for(;;) alt { + s := <-t.ctxt.kbd => + tk->keyboard(t, s); + s := <-t.ctxt.ptr => + tk->pointer(t, *s); + s := <-t.ctxt.ctl or + s = <-t.wreq => + tkclient->wmctl(t, s); + s := <-menubut => + if(s == "exit"){ + state = Stopped; + return; + } + tkclient->wmctl(t, s); + press := <-cmd => + case press { + "file" => + state = Stopped; + patterns := list of { + "*.mpg (MPEG movie files)", + "* (All Files)" + }; + fname = selectfile->filename(ctxt, t.image, "Locate MPEG files", + patterns, nil); + if(fname != nil) { + tk->cmd(t, ".f.name configure -text {"+fname+"}"); + tk->cmd(t, "update"); + } + "play" => + if (state != Stopped) { + state = Playing; + continue; + } + if(fname != nil) { + state = Playing; + spawn play(t, fname); + } + "step" => + if (state != Stopped) { + state = Stepping; + continue; + } + if(fname != nil) { + state = Stepping; + spawn play(t, fname); + } + "pause" => + if(state == Playing) + state = Paused; + "stop" => + state = Stopped; + } + } +} + +play(t: ref Toplevel, file: string) +{ + sp := list of { "Stop Play" }; + + fd := sys->open(file, Sys->OREAD); + if(fd == nil) { + dialog->prompt(ctxt, t.image, "error -fg red", "Open MPEG file", sys->sprint("%r"), 0, sp); + return; + } + m := mio->prepare(fd, file); + m.streaminit(Mpegio->VIDEO_STR0); + p := m.getpicture(1); + decode->init(m); + remap->init(m); + + canvr := canvsize(t); + o := Point(0, 0); + dx := canvr.dx(); + if(dx > m.width) + o.x = (dx - m.width)/2; + dy := canvr.dy(); + if(dy > m.height) + o.y = (dy - m.height)/2; + canvr.min = canvr.min.add(o); + canvr.max = canvr.min.add(Point(m.width, m.height)); + + if (depth != sdepth){ + chans := Draw->CMAP8; + case depth { + 0 => chans = Draw->GREY1; + 1 => chans = Draw->GREY2; + 2 => chans = Draw->GREY4; + 3 => chans = Draw->CMAP8; + 4 => chans = Draw->RGB16; + 5 => chans = Draw->RGB24; # ? + } + cvt = ctxt.display.newimage(Rect((0, 0), (m.width, m.height)), chans, 0, 0); + } + + f, pf: ref Mpegio->YCbCr; + for(;;) { + if(state == Stopped) + break; + case p.ptype { + Mpegio->IPIC => + f = decode->Idecode(p); + Mpegio->PPIC => + f = decode->Pdecode(p); + Mpegio->BPIC => + f = decode->Bdecode(p); + } + while(state == Paused) + sys->sleep(0); + if (p.ptype == Mpegio->BPIC) { + writepixels(t, canvr, remap->remap(f)); + if(state == Stepping) + state = Paused; + } else { + if (pf != nil) { + writepixels(t, canvr, remap->remap(pf)); + if(state == Stepping) + state = Paused; + } + pf = f; + } + if ((p = m.getpicture(1)) == nil) { + writepixels(t, canvr, remap->remap(pf)); + break; + } + } + state = Stopped; +} + +writepixels(t: ref Toplevel, r: Rect, b: array of byte) +{ + if (cvt != nil) { + cvt.writepixels(cvt.r, b); + t.image.draw(r, cvt, nil, (0, 0)); + } else + t.image.writepixels(r, b); +} + +canvsize(t: ref Toplevel): Rect +{ + r: Rect; + + r.min.x = int tk->cmd(t, ".c cget -actx"); + r.min.y = int tk->cmd(t, ".c cget -acty"); + r.max.x = r.min.x + int tk->cmd(t, ".c cget -width"); + r.max.y = r.min.y + int tk->cmd(t, ".c cget -height"); + + return r; +} diff --git a/appl/wm/mpeg/mpegio.b b/appl/wm/mpeg/mpegio.b new file mode 100644 index 00000000..3206776b --- /dev/null +++ b/appl/wm/mpeg/mpegio.b @@ -0,0 +1,870 @@ +implement Mpegio; + +# +# MPEG ISO 11172 IO module. +# + +include "sys.m"; +include "mpegio.m"; + +sys: Sys; + +init() +{ + sys = load Sys Sys->PATH; +} + +raisex(s: string) +{ + raise MEXCEPT + s; +} + +prepare(fd: ref Sys->FD, name: string): ref Mpegi +{ + m := ref Mpegi; + m.fd = fd; + m.name = name; + m.seek = 0; + m.looked = 0; + m.index = 0; + m.size = 0; + m.buff = array[MBSZ] of byte; + return m; +} + +Mpegi.startsys(m: self ref Mpegi) +{ + # 2.4.3.2 + m.xnextsc(PACK_SC); + m.packhdr(); + m.xnextsc(SYSHD_SC); + m.syssz = m.getw(); + m.boundmr = m.get22("boundmr"); + m.syspar = m.getw(); + if ((m.syspar & 16r20) == 0 || m.getb() != 16rFF) + m.fmterr("syspar"); + t := m.syssz - 6; + if (t <= 0 || (t % 3) != 0) + m.fmterr("syssz"); + t /= 3; + m.nstream = t; + m.streams = array[t] of Stream; + for (i := 0; i < t; i++) { + v := m.getb(); + if ((v & 16r80) == 0) + m.fmterr("streamid"); + w := m.getb(); + if ((w & 16rC0) != 16rC0) + m.fmterr("stream mark"); + m.streams[i] = (byte v, byte ((w >> 5) & 1), ((w & 16r1F) << 8) | m.getb(), nil); + } +} + +Mpegi.packetcp(m: self ref Mpegi): int +{ + while ((c := m.nextsc()) != STREAM_EC) { + case c { + PACK_SC => + m.packhdr(); + SYSHD_SC => + m.syshdr(); + * => + if (c < STREAM_BASE) + m.fmterr(sys->sprint("stream code %x", c)); + # 2.4.3.3 + l := m.getw(); + fd := m.getfd(c); + if (fd != nil) { + if (c != PRIVSTREAM2) + l -= m.stamps(); + if (m.log != nil) + sys->fprint(m.log, "%x %d %d\n", c & 16rFF, m.tell(), l); + m.cpn(fd, l); + } else + m.skipn(l); + return 1; + } + } + return 0; +} + +Mpegi.getfd(m: self ref Mpegi, c: int): ref Sys->FD +{ + id := byte c; + n := m.nstream; + for (i := 0; i < n; i++) { + if (m.streams[i].id == id) + return m.streams[i].fd; + } + return nil; +} + +Mpegi.packhdr(m: self ref Mpegi) +{ + # 2.4.3.2 + t := m.getb(); + if ((t & 16rF1) != 16r21) + m.fmterr("pack tag"); + m.packt0 = (t >> 1) & 7; + v := m.getb() << 22; + t = m.getb(); + if ((t & 1) == 0) + m.fmterr("packt mark 1"); + v |= ((t & ~1) << 15) | (m.getb() << 7); + t = m.getb(); + if ((t & 1) == 0) + m.fmterr("packt mark 2"); + m.packt1 = v | (t >> 1); + m.packmr = m.get22("packmr"); +} + +Mpegi.syshdr(m: self ref Mpegi) +{ + l := m.getw(); + if (l != m.syssz) + m.fmterr("syshdr size mismatch"); + m.skipn(l); +} + +Mpegi.stamps(m: self ref Mpegi): int +{ + # 2.4.3.3 + n := 1; + while ((c := m.getb()) == 16rFF) + n++; + if ((c >> 6) == 1) { + m.getb(); + c = m.getb(); + n += 2; + } + case c >> 4 { + 2 => + m.skipn(4); + n += 4; + 3 => + m.skipn(9); + n += 9; + * => + if (c != 16rF) + m.fmterr("stamps"); + } + return n; +} + +Mpegi.streaminit(m: self ref Mpegi, c: int) +{ + m.inittables(); + m.sid = c; + s := m.peeksc(); + if (s == PACK_SC) { + m.startsys(); + f := 0; + id := byte m.sid; + for (i := 0; i < m.nstream; i++) { + if (m.streams[i].id == id) { + f = 1; + break; + } + } + if (!f) + m.fmterr(sys->sprint("%x: stream not found", c)); + m.sseek(); + } else if (s == SEQUENCE_SC) { + m.sresid = -1; + m.slim = m.size; + } else + m.fmterr(sys->sprint("start code = %x", s)); + m.sbits = 0; +} + +Mpegi.sseek(m: self ref Mpegi) +{ + while ((c := m.nextsc()) != STREAM_EC) { + case c { + PACK_SC => + m.packhdr(); + SYSHD_SC => + m.syshdr(); + * => + if (c < STREAM_BASE) + m.fmterr(sys->sprint("stream code %x", c)); + # 2.4.3.3 + l := m.getw(); + if (c == m.sid) { + if (c != PRIVSTREAM2) + l -= m.stamps(); + n := m.size - m.index; + if (l <= n) { + m.slim = m.index + l; + m.sresid = 0; + } else { + m.slim = m.size; + m.sresid = l - n; + } + return; + } else + m.skipn(l); + } + } + m.fmterr("end of stream"); +} + +Mpegi.getpicture(m: self ref Mpegi, detail: int): ref Picture +{ + g := 0; + for (;;) { + case c := m.snextsc() { + SEQUENCE_SC => + m.seqhdr(); + GROUP_SC => + m.grphdr(); + g = 1; + PICTURE_SC => + p := m.picture(detail); + if (g) + p.flags |= GSTART; + return p; + SEQUENCE_EC => + return nil; + * => + m.fmterr(sys->sprint("start code %x", c)); + } + } +} + +Mpegi.seqhdr(m: self ref Mpegi) +{ + # 2.4.2.3 + c := m.sgetb(); + d := m.sgetb(); + m.width = (c << 4) | (d >> 4); + m.height = ((d & 16rF) << 8) | m.sgetb(); + c = m.sgetb(); + m.aspect = c >> 4; + m.frames = c & 16rF; + m.rate = m.sgetn(18); + m.smarker(); + m.vbv = m.sgetn(10); + m.flags = 0; + if (m.sgetn(1)) + m.flags |= CONSTRAINED; + if (m.sgetn(1)) + m.intra = m.getquant(); + if (m.sgetn(1)) + m.nintra = m.getquant(); + if (m.speeksc() == EXTENSION_SC) + m.sseeksc(); + if (m.speeksc() == USER_SC) + m.sseeksc(); +} + +Mpegi.grphdr(m: self ref Mpegi) +{ + # 2.4.2.4 + v := m.sgetb() << 17; + v |= m.sgetb() << 9; + v |= m.sgetb() << 1; + c := m.sgetb(); + m.smpte = v | (c >> 7); + if (c & (1 << 6)) + m.flags |= CLOSED; + else + m.flags &= ~CLOSED; + if (c & (1 << 5)) + m.flags |= BROKEN; + else + m.flags &= ~BROKEN; + if (m.speeksc() == EXTENSION_SC) + m.sseeksc(); + if (m.speeksc() == USER_SC) + m.sseeksc(); +} + +Mpegi.getquant(m: self ref Mpegi): array of int +{ + a := array[64] of int; + for (i := 0; i < 64; i++) + a[i] = m.sgetn(8); + return a; +} + +Mpegi.picture(m: self ref Mpegi, detail: int): ref Picture +{ + # 2.4.2.5 + p := ref Picture; + p.temporal = m.sgetn(10); + p.ptype = m.sgetn(3); + p.vbvdelay = m.sgetn(16); + p.flags = 0; + if (p.ptype == PPIC || p.ptype == BPIC) { + if (m.sgetn(1)) + p.flags |= FPFV; + p.forwfc = m.sgetn(3); + if (p.forwfc == 0) + m.fmterr("forwfc"); + p.forwfc--; + if (p.ptype == BPIC) { + if (m.sgetn(1)) + p.flags |= FPBV; + p.backfc = m.sgetn(3); + if (p.backfc == 0) + m.fmterr("backfc"); + p.backfc--; + } else + p.backfc = 0; + } else { + p.forwfc = 0; + p.backfc = 0; + } + while (m.sgetn(1)) + m.sgetn(8); + if (m.speeksc() == EXTENSION_SC) + m.sseeksc(); + if (m.speeksc() == USER_SC) + m.sseeksc(); + p.seek = m.tell() - 3; + if (m.sresid < 0) + p.eos = -1; + else + p.eos = m.seek - m.size + m.slim + m.sresid; + if (detail) + m.detail(p); + else + m.skipdetail(); + return p; +} + +Mpegi.detail(m: self ref Mpegi, p: ref Picture) +{ + l: list of ref Slice; + p.addr = -1; + while ((c := m.speeksc()) >= SLICE1_SC && c <= SLICEN_SC) + l = m.slice(p) :: l; + if (l == nil) + m.fmterr("slice sc"); + n := len l; + a := array[n] of ref Slice; + while (--n >= 0) { + a[n] = hd l; + l = tl l; + } + p.slices = a; +} + +Mpegi.skipdetail(m: self ref Mpegi) +{ + while ((c := m.speeksc()) >= SLICE1_SC && c <= SLICEN_SC) { + m.looked = 0; + m.sseeksc(); + } +} + +ESC, EOB, C0, C1, C2, C3, C4, C5, C6, C7: con -(iota + 1); + +include "mai.tab"; +include "mbi.tab"; +include "mbp.tab"; +include "mbb.tab"; +include "motion.tab"; +include "cbp.tab"; +include "cdc.tab"; +include "ydc.tab"; +include "rl0f.tab"; +include "rl0n.tab"; +include "c0.tab"; +include "c1.tab"; +include "c2.tab"; +include "c3.tab"; +include "c4.tab"; +include "c5.tab"; +include "c6.tab"; +include "c7.tab"; + +mbif := array[] of { + MB_I, + MB_I | MB_Q, +}; + +mbpf := array[] of { + MB_MF, + MB_P, + MB_P | MB_Q, + MB_P | MB_MF, + MB_P | MB_MF | MB_Q, + MB_I, + MB_I | MB_Q, +}; + +mbbf := array[] of { + MB_MF, + MB_MB, + MB_MB | MB_MF, + MB_P | MB_MF, + MB_P | MB_MF | MB_Q, + MB_P | MB_MB, + MB_P | MB_MB | MB_Q, + MB_P | MB_MB | MB_MF, + MB_P | MB_MB | MB_MF | MB_Q, + MB_I, + MB_I | MB_Q, +}; + +c_bits := array[] of { + c1_bits, + c2_bits, + c3_bits, + c4_bits, + c5_bits, + c6_bits, + c7_bits, +}; + +c_tables: array of array of Pair; + +patcode := array[] of { + 1<<5, 1<<4, 1<<3, 1<<2, 1<<1, 1<<0, +}; + +Mpegi.inittables() +{ + if (c_tables == nil) { + c_tables = array[] of { + c1_table, + c2_table, + c3_table, + c4_table, + c5_table, + c6_table, + c7_table, + }; + } +} + +Mpegi.slice(m: self ref Mpegi, p: ref Picture): ref Slice +{ + m.snextsc(); + s := ref Slice; + q := m.sgetn(5); + while (m.sgetn(1)) + m.sgetn(8); + x := p.addr; + l: list of ref MacroBlock; + while (m.speekn(23) != 0) { + while (m.speekn(11) == 16rF) + m.sbits -= 11; + while (m.speekn(11) == 16r8) { + x += 33; + m.sbits -= 11; + } + i := m.svlc(mai_table, mai_bits, "mai"); + x += i; + b := ref MacroBlock; + b.addr = x; + case p.ptype { + IPIC => + b.flags = mbif[m.svlc(mbi_table, mbi_bits, "mbi")]; + PPIC => + b.flags = mbpf[m.svlc(mbp_table, mbp_bits, "mbp")]; + BPIC => + b.flags = mbbf[m.svlc(mbb_table, mbb_bits, "mbb")]; + DPIC => + if (!m.sgetn(1)) + m.fmterr("mbd flags"); + b.flags = MB_I; + * => + m.fmterr("ptype"); + } + if (b.flags & MB_Q) + q = m.sgetn(5); + b.qscale = q; + if (b.flags & MB_MF) { + i = m.svlc(motion_table, motion_bits, "mhfc"); + b.mhfc = i; + if (i != 0 && p.forwfc != 0) + b.mhfr = m.sgetn(p.forwfc); + i = m.svlc(motion_table, motion_bits, "mvfc"); + b.mvfc = i; + if (i != 0 && p.forwfc != 0) + b.mvfr = m.sgetn(p.forwfc); + } + if (b.flags & MB_MB) { + i = m.svlc(motion_table, motion_bits, "mhbc"); + b.mhbc = i; + if (i != 0 && p.backfc != 0) + b.mhbr = m.sgetn(p.backfc); + i = m.svlc(motion_table, motion_bits, "mvbc"); + b.mvbc = i; + if (i != 0 && p.backfc != 0) + b.mvbr = m.sgetn(p.backfc); + } + if (b.flags & MB_I) + i = 16r3F; + else if (b.flags & MB_P) + i = m.svlc(cbp_table, cbp_bits, "cbp"); + else + i = 0; + b.pcode = i; + if (i != 0) { + b.rls = array[6] of array of Pair; + for (j := 0; j < 6; j++) { + if (i & patcode[j]) { + rl: list of Pair; + R, L: int; + if (b.flags & MB_I) { + if (j < 4) + L = m.svlc(ydc_table, ydc_bits, "ydc"); + else + L = m.svlc(cdc_table, cdc_bits, "cdc"); + if (L != 0) + L = m.sdiffn(L); + rl = (0, L) :: nil; + } else + rl = m.sdct(rl0f_table, "rl0f") :: nil; + if (p.ptype != DPIC) { + for (;;) { + (R, L) = m.sdct(rl0n_table, "rl0n"); + if (R == EOB) + break; + rl = (R, L) :: rl; + } + } + mn := len rl; + ma := array[mn] of Pair; + while (--mn >= 0) { + ma[mn] = hd rl; + rl = tl rl; + } + b.rls[j] = ma; + } + } + } + l = b :: l; + } + p.addr = x; + if (l == nil) + m.fmterr("macroblock"); + n := len l; + a := array[n] of ref MacroBlock; + while (--n >= 0) { + a[n] = hd l; + l = tl l; + } + s.blocks = a; + return s; +} + +Mpegi.cpn(m: self ref Mpegi, fd: ref Sys->FD, n: int) +{ + for (;;) { + r := m.size - m.index; + if (r >= n) { + if (sys->write(fd, m.buff[m.index:], n) < 0) + raisex(X_WRITE); + m.index += n; + return; + } + if (sys->write(fd, m.buff[m.index:], r) < 0) + raisex(X_WRITE); + m.fill(); + n -= r; + } +} + +Mpegi.fill(m: self ref Mpegi) +{ + n := sys->read(m.fd, m.buff, MBSZ); + if (n < 0) { + m.error = sys->sprint("%r"); + raisex(X_READ); + } + if (n == 0) + raisex(X_EOF); + m.seek += n; + m.index = 0; + m.size = n; +} + +Mpegi.tell(m: self ref Mpegi): int +{ + return m.seek - m.size + m.index; +} + +Mpegi.skipn(m: self ref Mpegi, n: int) +{ + for (;;) { + r := m.size - m.index; + if (r >= n) { + m.index += n; + return; + } + n -= r; + m.fill(); + } +} + +Mpegi.getb(m: self ref Mpegi): int +{ + if (m.index == m.size) + m.fill(); + return int m.buff[m.index++]; +} + +Mpegi.getw(m: self ref Mpegi): int +{ + t := m.getb(); + return (t << 8) | m.getb(); +} + +Mpegi.get22(m: self ref Mpegi, s: string): int +{ + u := m.getb(); + if ((u & 16r80) == 0) + m.fmterr(s + " mark 0"); + v := m.getb(); + w := m.getb(); + if ((w & 1) == 0) + m.fmterr(s + " mark 1"); + return ((u & 16r7F) << 15) | (v << 7) | (w >> 1); +} + +Mpegi.getsc(m: self ref Mpegi): int +{ + if (m.getb() != 0 || m.getb() != 0) + m.fmterr("start code 0s"); + while ((c := m.getb()) == 0) + ; + if (c != 1) + m.fmterr("start code 1"); + return 16r100 | m.getb(); +} + +Mpegi.nextsc(m: self ref Mpegi): int +{ + if (m.looked) { + m.looked = 0; + return m.value; + } else + return m.getsc(); +} + +Mpegi.peeksc(m: self ref Mpegi): int +{ + if (!m.looked) { + m.value = m.getsc(); + m.looked = 1; + } + return m.value; +} + +Mpegi.xnextsc(m: self ref Mpegi, x: int) +{ + c := m.nextsc(); + if (c != x) + m.fmterr(sys->sprint("startcode %x, got %x", x, c)); +} + +Mpegi.sfill(m: self ref Mpegi) +{ + r := m.sresid; + if (r < 0) { + m.fill(); + m.slim = m.size; + } else if (r > 0) { + m.fill(); + if (r <= m.size) { + m.slim = r; + m.sresid = 0; + } else { + m.slim = m.size; + m.sresid = r - m.size; + } + } else + m.sseek(); +} + +bits := array[] of { + 0, + 16r1, 16r3, 16r7, 16rF, + 16r1F, 16r3F, 16r7F, 16rFF, + 16r1FF, 16r3FF, 16r7FF, 16rFFF, + 16r1FFF, 16r3FFF, 16r7FFF, 16rFFFF, + 16r1FFFF, 16r3FFFF, 16r7FFFF, 16rFFFFF, + 16r1FFFFF, 16r3FFFFF, 16r7FFFFF, 16rFFFFFF, + 16r1FFFFFF, 16r3FFFFFF, 16r7FFFFFF, 16rFFFFFFF, + 16r1FFFFFFF, 16r3FFFFFFF, 16r7FFFFFFF, int 16rFFFFFFFF, +}; + +sign := array[] of { + 0, + 16r1, 16r2, 16r4, 16r8, + 16r10, 16r20, 16r40, 16r80, +}; + +Mpegi.sgetn(m: self ref Mpegi, n: int): int +{ + b := m.sbits; + v := m.svalue; + if (b < n) { + do { + v = (v << 8) | m.sgetb(); + b += 8; + } while (b < n); + m.svalue = v; + } + b -= n; + m.sbits = b; + return (v >> b) & bits[n]; +} + +Mpegi.sdiffn(m: self ref Mpegi, n: int): int +{ + i := m.sgetn(n); + if (i & sign[n]) + return i; + else + return i - bits[n]; +} + +Mpegi.speekn(m: self ref Mpegi, n: int): int +{ + b := m.sbits; + v := m.svalue; + if (b < n) { + do { + v = (v << 8) | m.sgetb(); + b += 8; + } while (b < n); + m.sbits = b; + m.svalue = v; + } + return (v >> (b - n)) & bits[n]; +} + +Mpegi.sgetb(m: self ref Mpegi): int +{ + if (m.index == m.slim) + m.sfill(); + return int m.buff[m.index++]; +} + +Mpegi.smarker(m: self ref Mpegi) +{ + if (!m.sgetn(1)) + m.fmterr("marker"); +} + +Mpegi.sgetsc(m: self ref Mpegi): int +{ + b := m.sbits; + if (b >= 8) { + if (b >= 16) { + if (b >= 24) { + case m.svalue & 16rFFFFFF { + 0 => + break; + 1 => + m.sbits = 0; + return 16r100 | m.sgetb(); + * => + m.fmterr("start code 0s - 3"); + } + } else if ((m.svalue & 16rFFFF) != 0) + m.fmterr("start code 0s - 2"); + } else if ((m.svalue & 16rFF) != 0 || m.sgetb() != 0) + m.fmterr("start code 0s - 1"); + } else if (m.sgetb() != 0 || m.sgetb() != 0) + m.fmterr("start code 0s"); + m.sbits = 0; + while ((c := m.sgetb()) == 0) + ; + if (c != 1) + m.fmterr("start code 1"); + return 16r100 | m.sgetb(); +} + +Mpegi.snextsc(m: self ref Mpegi): int +{ + if (m.looked) { + m.looked = 0; + return m.value; + } else + return m.sgetsc(); +} + +Mpegi.speeksc(m: self ref Mpegi): int +{ + if (!m.looked) { + m.value = m.sgetsc(); + m.looked = 1; + } + return m.value; +} + +Mpegi.sseeksc(m: self ref Mpegi) +{ + n := 0; + for (;;) { + case m.sgetb() { + 0 => + n++; + 1 => + if (n >= 2) { + m.value = 16r100 | m.sgetb(); + m.looked = 1; + return; + } + n = 0; + * => + n = 0; + } + } +} + +Mpegi.svlc(m: self ref Mpegi, a: array of Pair, n: int, s: string): int +{ + (b, v) := a[m.speekn(n)]; + if (v == UNDEF) + m.fmterr(s + " vlc"); + m.sbits -= b; + return v; +} + +Mpegi.sdct(m: self ref Mpegi, a: array of Triple, s: string): Pair +{ + (b, l, r) := a[m.speekn(rl0f_bits)]; + m.sbits -= b; + if (r < 0) { + case r { + EOB => + break; + ESC => + r = m.sgetn(6); + l = m.sgetn(8); + if (l == 0) { + l = m.sgetn(8); + if (l < 128) + m.fmterr(s + " esc +7"); + } else if (l == 128) { + l = m.sgetn(8) - 256; + if (l > -128) + m.fmterr(s + " esc -7"); + } else + l = (l << 24) >> 24; + C0 => + (b, l, r) = c0_table[m.speekn(c0_bits)]; + if (r == UNDEF) + m.fmterr(s + " c0 vlc"); + m.sbits -= b; + * => + r = C1 - r; + (l, r) = c_tables[r][m.sgetn(c_bits[r])]; + } + } + return (r, l); +} + +Mpegi.fmterr(m: self ref Mpegi, s: string) +{ + m.error = s; + raisex(X_FORMAT); +} diff --git a/appl/wm/mpeg/mpegio.m b/appl/wm/mpeg/mpegio.m new file mode 100644 index 00000000..378db8aa --- /dev/null +++ b/appl/wm/mpeg/mpegio.m @@ -0,0 +1,218 @@ +# +# MPEG ISO 11172 IO module. +# +Mpegio: module +{ + PATH: con "/dis/mpeg/mpegio.dis"; + + MBSZ: con Sys->ATOMICIO; + + PICTURE_SC: con 16r100; + SLICE1_SC: con 16r101; + SLICEN_SC: con 16r1AF; + USER_SC: con 16r1B2; + SEQUENCE_SC: con 16r1B3; + EXTENSION_SC: con 16r1B5; + SEQUENCE_EC: con 16r1B7; + GROUP_SC: con 16r1B8; + STREAM_EC: con 16r1B9; + PACK_SC: con 16r1BA; + SYSHD_SC: con 16r1BB; + STREAM_BASE: con 16r1BC; + PRIVSTREAM2: con 16r1BF; + AUDIO_STR0: con 16r1C0; + VIDEO_STR0: con 16r1E0; + + MEXCEPT: con "mpeg: "; + X_FORMAT: con "fmt error"; + X_READ: con "read error"; + X_WRITE: con "write error"; + X_EOF: con "premature eof"; + + UNDEF: con 100; + + CONSTRAINED, CLOSED, BROKEN: con 1 << iota; + FPFV, FPBV, GSTART: con 1 << iota; + + IPIC: con 1; + PPIC: con 2; + BPIC: con 3; + DPIC: con 4; + + ptypes: con "0IPBD"; + + MB_Q, MB_MF, MB_MB, MB_P, MB_I: con 1 << iota; + + Stream: adt + { + id: byte; + scale: byte; + bound: int; + fd: ref Sys->FD; + }; + + Picture: adt + { + seek: int; + eos: int; + temporal: int; + ptype: int; + vbvdelay: int; + flags: int; + forwfc: int; + backfc: int; + slices: array of ref Slice; + addr: int; + }; + + Slice: adt + { + blocks: array of ref MacroBlock; + }; + + MacroBlock: adt + { + flags: int; + qscale: int; + mhfc, mhfr, mvfc, mvfr: int; + mhbc, mhbr, mvbc, mvbr: int; + pcode: int; + rls: array of array of Pair; + addr: int; + }; + + YCbCr: adt + { + Y, Cb, Cr: array of byte; + }; + + Pair: type (int, int); + Triple: type (int, int, int); + + Mpegi: adt + { + fd: ref Sys->FD; + name: string; + error: string; + looked: int; + value: int; + # info + width: int; + height: int; + aspect: int; + frames: int; + rate: int; + vbv: int; + flags: int; + intra: array of int; + nintra: array of int; + smpte: int; + # real buffer + seek: int; + index: int; + size: int; + buff: array of byte; + # stream buffer + sid: int; # stream id + slim: int; # stream limit <= size + sresid: int; # stream residual (-1 entire file) + sbits: int; # bits remaining + svalue: int; # current value + + packt0: int; + packt1: int; + packmr: int; + syssz: int; + boundmr: int; + syspar: int; + nstream: int; + streams: array of Stream; + log: ref Sys->FD; + + startsys: fn(m: self ref Mpegi); + packhdr: fn(m: self ref Mpegi); + syshdr: fn(m: self ref Mpegi); + packetcp: fn(m: self ref Mpegi): int; + getfd: fn(m: self ref Mpegi, c: int): ref Sys->FD; + stamps: fn(m: self ref Mpegi): int; + + streaminit: fn(m: self ref Mpegi, c: int); + inittables: fn(); + sseek: fn(m: self ref Mpegi); + seqhdr: fn(m: self ref Mpegi); + grphdr: fn(m: self ref Mpegi); + getquant: fn(m: self ref Mpegi): array of int; + getpicture: fn(m: self ref Mpegi, detail: int): ref Picture; + picture: fn(m: self ref Mpegi, detail: int): ref Picture; + detail: fn(m: self ref Mpegi, p: ref Picture); + skipdetail: fn(m: self ref Mpegi); + slice: fn(m: self ref Mpegi, p: ref Picture): ref Slice; + + cpn: fn(m: self ref Mpegi, fd: ref Sys->FD, n: int); + fill: fn(m: self ref Mpegi); + tell: fn(m: self ref Mpegi): int; + skipn: fn(m: self ref Mpegi, n: int); + getb: fn(m: self ref Mpegi): int; + getw: fn(m: self ref Mpegi): int; + get22: fn(m: self ref Mpegi, s: string): int; + getsc: fn(m: self ref Mpegi): int; + nextsc: fn(m: self ref Mpegi): int; + peeksc: fn(m: self ref Mpegi): int; + xnextsc: fn(m: self ref Mpegi, code: int); + + sfill: fn(m: self ref Mpegi); + sgetb: fn(m: self ref Mpegi): int; + sgetn: fn(m: self ref Mpegi, n: int): int; + sdiffn: fn(m: self ref Mpegi, n: int): int; + sdct: fn(m: self ref Mpegi, a: array of Triple, s: string): Pair; + speekn: fn(m: self ref Mpegi, n: int): int; + smarker: fn(m: self ref Mpegi); + sgetsc: fn(m: self ref Mpegi): int; + snextsc: fn(m: self ref Mpegi): int; + speeksc: fn(m: self ref Mpegi): int; + sseeksc: fn(m: self ref Mpegi); + svlc: fn(m: self ref Mpegi, a: array of Pair, n: int, s: string): int; + + fmterr: fn(m: self ref Mpegi, s: string); + }; + + init: fn(); + prepare: fn(fd: ref Sys->FD, name: string): ref Mpegi; + raisex: fn(s: string); +}; + +Mpegd: module +{ + PATH: con "/dis/mpeg/decode.dis"; + PATH4: con "/dis/mpeg/decode4.dis"; + + init: fn(m: ref Mpegio->Mpegi); + Idecode: fn(p: ref Mpegio->Picture): ref Mpegio->YCbCr; + Pdecode: fn(p: ref Mpegio->Picture): ref Mpegio->YCbCr; + Bdecode: fn(p: ref Mpegio->Picture): ref Mpegio->YCbCr; + Bdecode2: fn(p: ref Mpegio->Picture, f0, f1: ref Mpegio->YCbCr): ref Mpegio->YCbCr; +}; + +IDCT: module +{ + FPATH: con "/dis/mpeg/fltidct.dis"; # based on rob's jpeg + RPATH: con "/dis/mpeg/refidct.dis"; # reference (full idct) + SPATH: con "/dis/mpeg/scidct.dis"; # scaled integer implementation + XPATH: con "/dis/mpeg/fixidct.dis"; # nasty fixed point + PATH: con SPATH; + + init: fn(); + idct: fn(block: array of int); +}; + +Remap: module +{ + PATH: con "/dis/mpeg/remap.dis"; + PATH1: con "/dis/mpeg/remap1.dis"; + PATH2: con "/dis/mpeg/remap2.dis"; + PATH4: con "/dis/mpeg/remap4.dis"; + PATH24: con "/dis/mpeg/remap24.dis"; + + init: fn(m: ref Mpegio->Mpegi); + remap: fn(p: ref Mpegio->YCbCr): array of byte; +}; diff --git a/appl/wm/mpeg/refidct.b b/appl/wm/mpeg/refidct.b new file mode 100644 index 00000000..e02ab1f7 --- /dev/null +++ b/appl/wm/mpeg/refidct.b @@ -0,0 +1,58 @@ +implement IDCT; + +include "sys.m"; +include "math.m"; +include "mpegio.m"; + +sys: Sys; +math: Math; + +# +# Reference IDCT. Full expanded 2-d IDCT. +# + +coeff: array of array of real; + +init() +{ + sys = load Sys Sys->PATH; + math = load Math Math->PATH; + if (math == nil) { + sys->fprint(sys->fildes(2), "could not load %s: %r\n", Math->PATH); + exit; + } + init_idct(); +} + +init_idct() +{ + coeff = array[8] of array of real; + for (f := 0; f < 8; f++) { + coeff[f] = array[8] of real; + s := 0.5; + if (f == 0) + s = math->sqrt(0.125); + a := real f * (Math->Pi / 8.0); + for (t := 0; t < 8; t++) + coeff[f][t] = s * math->cos(a * (real t + 0.5)); + } +} + +idct(block: array of int) +{ + tmp := array[64] of real; + for (i := 0; i < 8; i++) + for (j := 0; j < 8; j++) { + p := 0.0; + for (k := 0; k < 8; k++) + p += coeff[k][j] * real block[8 * i + k]; + tmp[8 * i + j] = p; + } + for (j = 0; j < 8; j++) + for (i = 0; i < 8; i++) { + p := 0.0; + for (k := 0; k < 8; k++) + p += coeff[k][i] * tmp[8 * k + j]; + block[8 * i + j] = int p; + } +} diff --git a/appl/wm/mpeg/remap.b b/appl/wm/mpeg/remap.b new file mode 100644 index 00000000..4432048c --- /dev/null +++ b/appl/wm/mpeg/remap.b @@ -0,0 +1,128 @@ +implement Remap; + +include "sys.m"; +include "mpegio.m"; + +Mpegi, YCbCr: import Mpegio; + +CLOFF: con 255; + +width, height, w2, h2: int; +out: array of byte; +ered, egrn, eblu: array of int; +b0r1, b1, r0: array of int; +clamp := array[CLOFF + 256 + CLOFF] of int; +clamp16 := array[CLOFF + 256 + CLOFF] of int; + +init(m: ref Mpegi) +{ + width = m.width; + height = m.height; + w2 = width >> 1; + h2 = height >> 1; + out = array[width * height] of byte; + b0r1 = array[w2] of int; + b1 = array[w2] of int; + r0 = array[w2] of int; + ered = array[width + 1] of int; + egrn = array[width + 1] of int; + eblu = array[width + 1] of int; + for (i := 0; i < CLOFF; i++) { + clamp[i] = 0; + clamp16[i] = 0; + } + for (i = 0; i < 256; i++) { + clamp[i + CLOFF] = i; + clamp16[i + CLOFF] = i >> 4; + } + for (i = CLOFF + 256; i < CLOFF + 256 + CLOFF; i++) { + clamp[i] = 255; + clamp16[i] = 255 >> 4; + } +} + +include "closest.m"; +include "rgbvmap.m"; + +# rgb(y, cb, cr: int): (int, int, int) +# { +# Y := real y; +# Cb := real (cb - 128); +# Cr := real (cr - 128); +# r := int (Y+1.402*Cr); +# g := int (Y-0.34414*Cb-0.71414*Cr); +# b := int (Y+1.772*Cb); +# return (r, g, b); +# } + +B: con 16; +M: con (1 << B); +B0: con int (-0.34414 * real M); +B1: con int (1.772 * real M); +R0: con int (1.402 * real M); +R1: con int (-0.71414 * real M); + +remap(p: ref Mpegio->YCbCr): array of byte +{ + Y := p.Y; + Cb := p.Cb; + Cr := p.Cr; + for (e := 0; e <= width; e++) + ered[e] = 0; + egrn[0:] = ered[0:]; + eblu[0:] = ered[0:]; + m := 0; + n := 0; + for (i := 0; i < h2; i++) { + for (j := 0; j < w2; j++) { + cb := int Cb[m] - 128; + cr := int Cr[m] - 128; + b0r1[j] = B0 * cb + R1 * cr; + b1[j] = B1 * cb; + r0[j] = R0 * cr; + m++; + } + j = 2; + do { + ex := 0; + er := 0; + eg := 0; + eb := 0; + for (k := 0; k < w2; k++) { + l := 2; + do { + y := int Y[n] << B; + r := clamp[((y + r0[k]) >> B) + CLOFF] + ered[ex]; + g := clamp[((y + b0r1[k]) >> B) + CLOFF] + egrn[ex]; + b := clamp[((y + b1[k]) >> B) + CLOFF] + eblu[ex]; + rc := clamp16[r + CLOFF]; + gc := clamp16[g + CLOFF]; + bc := clamp16[b + CLOFF]; + col := int closest[bc + 16 * (gc + 16 * rc)]; + out[n++] = byte col; + + col *= 3; + r -= int rgbvmap[col + 0]; + t := (3 * r) >> 4; + ered[ex] = t + er; + ered[ex + 1] += t; + er = r - 3 * t; + + g -= int rgbvmap[col + 1]; + t = (3 * g) >> 4; + egrn[ex] = t + eg; + egrn[ex + 1] += t; + eg = g - 3 * t; + + b -= int rgbvmap[col + 2]; + t = (3 * b) >> 4; + eblu[ex] = t + eb; + eblu[ex + 1] += t; + eb = b - 3 * t; + ex++; + } while (--l > 0); + } + } while (--j > 0); + } + return out; +} diff --git a/appl/wm/mpeg/remap1.b b/appl/wm/mpeg/remap1.b new file mode 100644 index 00000000..09ad4646 --- /dev/null +++ b/appl/wm/mpeg/remap1.b @@ -0,0 +1,116 @@ +implement Remap; + +include "sys.m"; +include "mpegio.m"; + +Mpegi, YCbCr: import Mpegio; + +CLOFF: con 511; + +width, height, w8: int; +out: array of byte; +elum: array of int; +clamp2 := array[CLOFF + 256 + CLOFF] of int; + +init(m: ref Mpegi) +{ + width = m.width; + height = m.height; + w8 = width >> 3; + out = array[w8 * height] of byte; + elum = array[width + 1] of int; + for (i := 0; i < CLOFF; i++) + clamp2[i] = 0; + for (i = 0; i < 256; i++) + clamp2[i + CLOFF] = i >> 7; + for (i = CLOFF + 256; i < CLOFF + 256 + CLOFF; i++) + clamp2[i] = 255 >> 7; +} + +remap(p: ref Mpegio->YCbCr): array of byte +{ + Y := p.Y; + for (e := 0; e <= width; e++) + elum[e] = 0; + m := 0; + n := 0; + for (i := 0; i < height; i++) { + el := 0; + ex := 0; + for (k := 0; k < w8; k++) { + y := (256 - int Y[n++]) + elum[ex]; + l := clamp2[y + CLOFF] << 7; + b := l; + y -= l; + t := (3 * y) >> 4; + elum[ex] = t + el; + elum[ex + 1] += t; + el = y - 3 * t; + ex++; + y = (256 - int Y[n++]) + elum[ex]; + l = clamp2[y + CLOFF]; + b |= l << 6; + y -= l << 7; + t = (3 * y) >> 4; + elum[ex] = t + el; + elum[ex + 1] += t; + el = y - 3 * t; + ex++; + y = (256 - int Y[n++]) + elum[ex]; + l = clamp2[y + CLOFF]; + b |= l << 5; + y -= l << 7; + t = (3 * y) >> 4; + elum[ex] = t + el; + elum[ex + 1] += t; + el = y - 3 * t; + ex++; + y = (256 - int Y[n++]) + elum[ex]; + l = clamp2[y + CLOFF]; + b |= l << 4; + y -= l << 7; + t = (3 * y) >> 4; + elum[ex] = t + el; + elum[ex + 1] += t; + el = y - 3 * t; + ex++; + y = (256 - int Y[n++]) + elum[ex]; + l = clamp2[y + CLOFF]; + b |= l << 3; + y -= l << 7; + t = (3 * y) >> 4; + elum[ex] = t + el; + elum[ex + 1] += t; + el = y - 3 * t; + ex++; + y = (256 - int Y[n++]) + elum[ex]; + l = clamp2[y + CLOFF]; + b |= l << 2; + y -= l << 7; + t = (3 * y) >> 4; + elum[ex] = t + el; + elum[ex + 1] += t; + el = y - 3 * t; + ex++; + y = (256 - int Y[n++]) + elum[ex]; + l = clamp2[y + CLOFF]; + b |= l << 1; + y -= l << 7; + t = (3 * y) >> 4; + elum[ex] = t + el; + elum[ex + 1] += t; + el = y - 3 * t; + ex++; + y = (256 - int Y[n++]) + elum[ex]; + l = clamp2[y + CLOFF]; + out[m++] = byte (b | l); + y -= l << 7; + t = (3 * y) >> 4; + elum[ex] = t + el; + elum[ex + 1] += t; + el = y - 3 * t; + ex++; + } + } + return out; +} diff --git a/appl/wm/mpeg/remap2.b b/appl/wm/mpeg/remap2.b new file mode 100644 index 00000000..5bae164f --- /dev/null +++ b/appl/wm/mpeg/remap2.b @@ -0,0 +1,80 @@ +implement Remap; + +include "sys.m"; +include "mpegio.m"; + +Mpegi, YCbCr: import Mpegio; + +CLOFF: con 255; + +width, height, w4: int; +out: array of byte; +elum: array of int; +clamp4 := array[CLOFF + 256 + CLOFF] of int; + +init(m: ref Mpegi) +{ + width = m.width; + height = m.height; + w4 = width >> 2; + out = array[w4 * height] of byte; + elum = array[width + 1] of int; + for (i := 0; i < CLOFF; i++) + clamp4[i] = 0; + for (i = 0; i < 256; i++) + clamp4[i + CLOFF] = i >> 6; + for (i = CLOFF + 256; i < CLOFF + 256 + CLOFF; i++) + clamp4[i] = 255 >> 6; +} + +remap(p: ref Mpegio->YCbCr): array of byte +{ + Y := p.Y; + for (e := 0; e <= width; e++) + elum[e] = 0; + m := 0; + n := 0; + for (i := 0; i < height; i++) { + el := 0; + ex := 0; + for (k := 0; k < w4; k++) { + y := (256 - int Y[n++]) + elum[ex]; + l := clamp4[y + CLOFF] << 6; + b := l; + y -= l; + t := (3 * y) >> 4; + elum[ex] = t + el; + elum[ex + 1] += t; + el = y - 3 * t; + ex++; + y = (256 - int Y[n++]) + elum[ex]; + l = clamp4[y + CLOFF]; + b |= l << 4; + y -= l << 6; + t = (3 * y) >> 4; + elum[ex] = t + el; + elum[ex + 1] += t; + el = y - 3 * t; + ex++; + y = (256 - int Y[n++]) + elum[ex]; + l = clamp4[y + CLOFF]; + b |= l << 2; + y -= l << 6; + t = (3 * y) >> 4; + elum[ex] = t + el; + elum[ex + 1] += t; + el = y - 3 * t; + ex++; + y = (256 - int Y[n++]) + elum[ex]; + l = clamp4[y + CLOFF]; + out[m++] = byte (b | l); + y -= l << 6; + t = (3 * y) >> 4; + elum[ex] = t + el; + elum[ex + 1] += t; + el = y - 3 * t; + ex++; + } + } + return out; +} diff --git a/appl/wm/mpeg/remap24.b b/appl/wm/mpeg/remap24.b new file mode 100644 index 00000000..23e80815 --- /dev/null +++ b/appl/wm/mpeg/remap24.b @@ -0,0 +1,82 @@ +implement Remap; + +include "sys.m"; +include "mpegio.m"; + +Mpegi, YCbCr: import Mpegio; + +CLOFF: con 255; + +width, height, w2, h2: int; +out: array of byte; +b0r1, b1, r0: array of int; +clamp := array[CLOFF + 256 + CLOFF] of byte; + +init(m: ref Mpegi) +{ + width = m.width; + height = m.height; + w2 = width >> 1; + h2 = height >> 1; + out = array[3 * width * height] of byte; + b0r1 = array[w2] of int; + b1 = array[w2] of int; + r0 = array[w2] of int; + for (i := 0; i < CLOFF; i++) + clamp[i] = byte 0; + for (i = 0; i < 256; i++) + clamp[i + CLOFF] = byte i; + for (i = CLOFF + 256; i < CLOFF + 256 + CLOFF; i++) + clamp[i] = byte 255; +} + +# rgb(y, cb, cr: int): (int, int, int) +# { +# Y := real y; +# Cb := real (cb - 128); +# Cr := real (cr - 128); +# r := int (Y+1.402*Cr); +# g := int (Y-0.34414*Cb-0.71414*Cr); +# b := int (Y+1.772*Cb); +# return (r, g, b); +# } + +B: con 16; +M: con (1 << B); +B0: con int (-0.34414 * real M); +B1: con int (1.772 * real M); +R0: con int (1.402 * real M); +R1: con int (-0.71414 * real M); + +remap(p: ref Mpegio->YCbCr): array of byte +{ + Y := p.Y; + Cb := p.Cb; + Cr := p.Cr; + m := 0; + n := 0; + x := 0; + for (i := 0; i < h2; i++) { + for (j := 0; j < w2; j++) { + cb := int Cb[m] - 128; + cr := int Cr[m] - 128; + b0r1[j] = B0 * cb + R1 * cr; + b1[j] = B1 * cb; + r0[j] = R0 * cr; + m++; + } + j = 2; + do { + for (k := 0; k < w2; k++) { + l := 2; + do { + y := int Y[n++] << B; + out[x++] = clamp[((y + r0[k]) >> B) + CLOFF]; + out[x++] = clamp[((y + b0r1[k]) >> B) + CLOFF]; + out[x++] = clamp[((y + b1[k]) >> B) + CLOFF]; + } while (--l > 0); + } + } while (--j > 0); + } + return out; +} diff --git a/appl/wm/mpeg/remap4.b b/appl/wm/mpeg/remap4.b new file mode 100644 index 00000000..20566fc2 --- /dev/null +++ b/appl/wm/mpeg/remap4.b @@ -0,0 +1,62 @@ +implement Remap; + +include "sys.m"; +include "mpegio.m"; + +Mpegi, YCbCr: import Mpegio; + +CLOFF: con 255; + +width, height, w2: int; +out: array of byte; +elum: array of int; +clamp16 := array[CLOFF + 256 + CLOFF] of int; + +init(m: ref Mpegi) +{ + width = m.width; + height = m.height; + w2 = width >> 1; + out = array[w2 * height] of byte; + elum = array[width + 1] of int; + for (i := 0; i < CLOFF; i++) + clamp16[i] = 0; + for (i = 0; i < 256; i++) + clamp16[i + CLOFF] = i >> 4; + for (i = CLOFF + 256; i < CLOFF + 256 + CLOFF; i++) + clamp16[i] = 255 >> 4; +} + +remap(p: ref Mpegio->YCbCr): array of byte +{ + Y := p.Y; + for (e := 0; e <= width; e++) + elum[e] = 0; + m := 0; + n := 0; + for (i := 0; i < height; i++) { + el := 0; + ex := 0; + for (k := 0; k < w2; k++) { + y := (256 - int Y[n++]) + elum[ex]; + l := clamp16[y + CLOFF] << 4; + b := l; + y -= l; + t := (3 * y) >> 4; + elum[ex] = t + el; + elum[ex + 1] += t; + el = y - 3 * t; + ex++; + y = (256 - int Y[n++]) + elum[ex]; + l = clamp16[y + CLOFF]; + out[m++] = byte (b | l); + y -= l << 4; + t = (3 * y) >> 4; + elum[ex] = t + el; + elum[ex + 1] += t; + el = y - 3 * t; + ex++; + } + } + return out; +} diff --git a/appl/wm/mpeg/remap8.b b/appl/wm/mpeg/remap8.b new file mode 100644 index 00000000..957b72aa --- /dev/null +++ b/appl/wm/mpeg/remap8.b @@ -0,0 +1,84 @@ +implement Remap; + +include "sys.m"; +include "mpegio.m"; + +Mpegi, YCbCr: import Mpegio; + +CLOFF: con 255; + +width, height, w2, h2: int; +out: array of byte; +b0r1, b1, r0: array of int; +clamp16 := array[CLOFF + 256 + CLOFF] of int; + +init(m: ref Mpegi) +{ + width = m.width; + height = m.height; + w2 = width >> 1; + h2 = height >> 1; + out = array[width * height] of byte; + b0r1 = array[w2] of int; + b1 = array[w2] of int; + r0 = array[w2] of int; + for (i := 0; i < CLOFF; i++) + clamp16[i] = 0; + for (i = 0; i < 256; i++) + clamp16[i + CLOFF] = i >> 4; + for (i = CLOFF + 256; i < CLOFF + 256 + CLOFF; i++) + clamp16[i] = 255 >> 4; +} + +include "closest.m"; + +# rgb(y, cb, cr: int): (int, int, int) +# { +# Y := real y; +# Cb := real (cb - 128); +# Cr := real (cr - 128); +# r := int (Y+1.402*Cr); +# g := int (Y-0.34414*Cb-0.71414*Cr); +# b := int (Y+1.772*Cb); +# return (r, g, b); +# } + +B: con 16; +M: con (1 << B); +B0: con int (-0.34414 * real M); +B1: con int (1.772 * real M); +R0: con int (1.402 * real M); +R1: con int (-0.71414 * real M); + +remap(p: ref Mpegio->YCbCr): array of byte +{ + Y := p.Y; + Cb := p.Cb; + Cr := p.Cr; + m := 0; + n := 0; + for (i := 0; i < h2; i++) { + for (j := 0; j < w2; j++) { + cb := int Cb[m] - 128; + cr := int Cr[m] - 128; + b0r1[j] = B0 * cb + R1 * cr; + b1[j] = B1 * cb; + r0[j] = R0 * cr; + m++; + } + j = 2; + do { + for (k := 0; k < w2; k++) { + l := 2; + do { + y := int Y[n] << B; + rc := clamp16[((y + r0[k]) >> B) + CLOFF]; + gc := clamp16[((y + b0r1[k]) >> B) + CLOFF]; + bc := clamp16[((y + b1[k]) >> B) + CLOFF]; + out[n++] = closest[bc + 16 * (gc + 16 * rc)]; + } while (--l > 0); + } + } while (--j > 0); + } + return out; +} diff --git a/appl/wm/mpeg/rgbvmap.m b/appl/wm/mpeg/rgbvmap.m new file mode 100644 index 00000000..d53b1b04 --- /dev/null +++ b/appl/wm/mpeg/rgbvmap.m @@ -0,0 +1,258 @@ +rgbvmap := array[3*256] of { + byte 255,byte 255,byte 255, + byte 255,byte 255,byte 170, + byte 255,byte 255,byte 85, + byte 255,byte 255,byte 0, + byte 255,byte 170,byte 255, + byte 255,byte 170,byte 170, + byte 255,byte 170,byte 85, + byte 255,byte 170,byte 0, + byte 255,byte 85,byte 255, + byte 255,byte 85,byte 170, + byte 255,byte 85,byte 85, + byte 255,byte 85,byte 0, + byte 255,byte 0,byte 255, + byte 255,byte 0,byte 170, + byte 255,byte 0,byte 85, + byte 255,byte 0,byte 0, + byte 238,byte 0,byte 0, + byte 238,byte 238,byte 238, + byte 238,byte 238,byte 158, + byte 238,byte 238,byte 79, + byte 238,byte 238,byte 0, + byte 238,byte 158,byte 238, + byte 238,byte 158,byte 158, + byte 238,byte 158,byte 79, + byte 238,byte 158,byte 0, + byte 238,byte 79,byte 238, + byte 238,byte 79,byte 158, + byte 238,byte 79,byte 79, + byte 238,byte 79,byte 0, + byte 238,byte 0,byte 238, + byte 238,byte 0,byte 158, + byte 238,byte 0,byte 79, + byte 221,byte 0,byte 73, + byte 221,byte 0,byte 0, + byte 221,byte 221,byte 221, + byte 221,byte 221,byte 147, + byte 221,byte 221,byte 73, + byte 221,byte 221,byte 0, + byte 221,byte 147,byte 221, + byte 221,byte 147,byte 147, + byte 221,byte 147,byte 73, + byte 221,byte 147,byte 0, + byte 221,byte 73,byte 221, + byte 221,byte 73,byte 147, + byte 221,byte 73,byte 73, + byte 221,byte 73,byte 0, + byte 221,byte 0,byte 221, + byte 221,byte 0,byte 147, + byte 204,byte 0,byte 136, + byte 204,byte 0,byte 68, + byte 204,byte 0,byte 0, + byte 204,byte 204,byte 204, + byte 204,byte 204,byte 136, + byte 204,byte 204,byte 68, + byte 204,byte 204,byte 0, + byte 204,byte 136,byte 204, + byte 204,byte 136,byte 136, + byte 204,byte 136,byte 68, + byte 204,byte 136,byte 0, + byte 204,byte 68,byte 204, + byte 204,byte 68,byte 136, + byte 204,byte 68,byte 68, + byte 204,byte 68,byte 0, + byte 204,byte 0,byte 204, + byte 170,byte 255,byte 170, + byte 170,byte 255,byte 85, + byte 170,byte 255,byte 0, + byte 170,byte 170,byte 255, + byte 187,byte 187,byte 187, + byte 187,byte 187,byte 93, + byte 187,byte 187,byte 0, + byte 170,byte 85,byte 255, + byte 187,byte 93,byte 187, + byte 187,byte 93,byte 93, + byte 187,byte 93,byte 0, + byte 170,byte 0,byte 255, + byte 187,byte 0,byte 187, + byte 187,byte 0,byte 93, + byte 187,byte 0,byte 0, + byte 170,byte 255,byte 255, + byte 158,byte 238,byte 238, + byte 158,byte 238,byte 158, + byte 158,byte 238,byte 79, + byte 158,byte 238,byte 0, + byte 158,byte 158,byte 238, + byte 170,byte 170,byte 170, + byte 170,byte 170,byte 85, + byte 170,byte 170,byte 0, + byte 158,byte 79,byte 238, + byte 170,byte 85,byte 170, + byte 170,byte 85,byte 85, + byte 170,byte 85,byte 0, + byte 158,byte 0,byte 238, + byte 170,byte 0,byte 170, + byte 170,byte 0,byte 85, + byte 170,byte 0,byte 0, + byte 153,byte 0,byte 0, + byte 147,byte 221,byte 221, + byte 147,byte 221,byte 147, + byte 147,byte 221,byte 73, + byte 147,byte 221,byte 0, + byte 147,byte 147,byte 221, + byte 153,byte 153,byte 153, + byte 153,byte 153,byte 76, + byte 153,byte 153,byte 0, + byte 147,byte 73,byte 221, + byte 153,byte 76,byte 153, + byte 153,byte 76,byte 76, + byte 153,byte 76,byte 0, + byte 147,byte 0,byte 221, + byte 153,byte 0,byte 153, + byte 153,byte 0,byte 76, + byte 136,byte 0,byte 68, + byte 136,byte 0,byte 0, + byte 136,byte 204,byte 204, + byte 136,byte 204,byte 136, + byte 136,byte 204,byte 68, + byte 136,byte 204,byte 0, + byte 136,byte 136,byte 204, + byte 136,byte 136,byte 136, + byte 136,byte 136,byte 68, + byte 136,byte 136,byte 0, + byte 136,byte 68,byte 204, + byte 136,byte 68,byte 136, + byte 136,byte 68,byte 68, + byte 136,byte 68,byte 0, + byte 136,byte 0,byte 204, + byte 136,byte 0,byte 136, + byte 85,byte 255,byte 85, + byte 85,byte 255,byte 0, + byte 85,byte 170,byte 255, + byte 93,byte 187,byte 187, + byte 93,byte 187,byte 93, + byte 93,byte 187,byte 0, + byte 85,byte 85,byte 255, + byte 93,byte 93,byte 187, + byte 119,byte 119,byte 119, + byte 119,byte 119,byte 0, + byte 85,byte 0,byte 255, + byte 93,byte 0,byte 187, + byte 119,byte 0,byte 119, + byte 119,byte 0,byte 0, + byte 85,byte 255,byte 255, + byte 85,byte 255,byte 170, + byte 79,byte 238,byte 158, + byte 79,byte 238,byte 79, + byte 79,byte 238,byte 0, + byte 79,byte 158,byte 238, + byte 85,byte 170,byte 170, + byte 85,byte 170,byte 85, + byte 85,byte 170,byte 0, + byte 79,byte 79,byte 238, + byte 85,byte 85,byte 170, + byte 102,byte 102,byte 102, + byte 102,byte 102,byte 0, + byte 79,byte 0,byte 238, + byte 85,byte 0,byte 170, + byte 102,byte 0,byte 102, + byte 102,byte 0,byte 0, + byte 79,byte 238,byte 238, + byte 73,byte 221,byte 221, + byte 73,byte 221,byte 147, + byte 73,byte 221,byte 73, + byte 73,byte 221,byte 0, + byte 73,byte 147,byte 221, + byte 76,byte 153,byte 153, + byte 76,byte 153,byte 76, + byte 76,byte 153,byte 0, + byte 73,byte 73,byte 221, + byte 76,byte 76,byte 153, + byte 85,byte 85,byte 85, + byte 85,byte 85,byte 0, + byte 73,byte 0,byte 221, + byte 76,byte 0,byte 153, + byte 85,byte 0,byte 85, + byte 85,byte 0,byte 0, + byte 68,byte 0,byte 0, + byte 68,byte 204,byte 204, + byte 68,byte 204,byte 136, + byte 68,byte 204,byte 68, + byte 68,byte 204,byte 0, + byte 68,byte 136,byte 204, + byte 68,byte 136,byte 136, + byte 68,byte 136,byte 68, + byte 68,byte 136,byte 0, + byte 68,byte 68,byte 204, + byte 68,byte 68,byte 136, + byte 68,byte 68,byte 68, + byte 68,byte 68,byte 0, + byte 68,byte 0,byte 204, + byte 68,byte 0,byte 136, + byte 68,byte 0,byte 68, + byte 0,byte 255,byte 0, + byte 0,byte 170,byte 255, + byte 0,byte 187,byte 187, + byte 0,byte 187,byte 93, + byte 0,byte 187,byte 0, + byte 0,byte 85,byte 255, + byte 0,byte 93,byte 187, + byte 0,byte 119,byte 119, + byte 0,byte 119,byte 0, + byte 0,byte 0,byte 255, + byte 0,byte 0,byte 187, + byte 0,byte 0,byte 119, + byte 51,byte 51,byte 51, + byte 0,byte 255,byte 255, + byte 0,byte 255,byte 170, + byte 0,byte 255,byte 85, + byte 0,byte 238,byte 79, + byte 0,byte 238,byte 0, + byte 0,byte 158,byte 238, + byte 0,byte 170,byte 170, + byte 0,byte 170,byte 85, + byte 0,byte 170,byte 0, + byte 0,byte 79,byte 238, + byte 0,byte 85,byte 170, + byte 0,byte 102,byte 102, + byte 0,byte 102,byte 0, + byte 0,byte 0,byte 238, + byte 0,byte 0,byte 170, + byte 0,byte 0,byte 102, + byte 34,byte 34,byte 34, + byte 0,byte 238,byte 238, + byte 0,byte 238,byte 158, + byte 0,byte 221,byte 147, + byte 0,byte 221,byte 73, + byte 0,byte 221,byte 0, + byte 0,byte 147,byte 221, + byte 0,byte 153,byte 153, + byte 0,byte 153,byte 76, + byte 0,byte 153,byte 0, + byte 0,byte 73,byte 221, + byte 0,byte 76,byte 153, + byte 0,byte 85,byte 85, + byte 0,byte 85,byte 0, + byte 0,byte 0,byte 221, + byte 0,byte 0,byte 153, + byte 0,byte 0,byte 85, + byte 17,byte 17,byte 17, + byte 0,byte 221,byte 221, + byte 0,byte 204,byte 204, + byte 0,byte 204,byte 136, + byte 0,byte 204,byte 68, + byte 0,byte 204,byte 0, + byte 0,byte 136,byte 204, + byte 0,byte 136,byte 136, + byte 0,byte 136,byte 68, + byte 0,byte 136,byte 0, + byte 0,byte 68,byte 204, + byte 0,byte 68,byte 136, + byte 0,byte 68,byte 68, + byte 0,byte 68,byte 0, + byte 0,byte 0,byte 204, + byte 0,byte 0,byte 136, + byte 0,byte 0,byte 68, + byte 0,byte 0,byte 0, +}; diff --git a/appl/wm/mpeg/rl0f.tab b/appl/wm/mpeg/rl0f.tab new file mode 100644 index 00000000..38da34ee --- /dev/null +++ b/appl/wm/mpeg/rl0f.tab @@ -0,0 +1,517 @@ +# vlc -c rl0f +rl0f_size: con 512; +rl0f_bits: con 9; +rl0f_table:= array[] of { + (9, 0,C0), + (9, 0,C1), + (9, 0,C2), + (9, 0,C3), + (9, 0,C4), + (9, 0,C5), + (9, 0,C6), + (9, 0,C7), + (6, 0,ESC), + (6, 0,ESC), + (6, 0,ESC), + (6, 0,ESC), + (6, 0,ESC), + (6, 0,ESC), + (6, 0,ESC), + (6, 0,ESC), + (8, 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), + (7, 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), + (9, 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), + (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, -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), + (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, -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), + (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, -1,1), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, 1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), + (2, -1,0), +}; diff --git a/appl/wm/mpeg/rl0f.vlc b/appl/wm/mpeg/rl0f.vlc new file mode 100644 index 00000000..1f9eb590 --- /dev/null +++ b/appl/wm/mpeg/rl0f.vlc @@ -0,0 +1,34 @@ +# Run/Level First base (first 9 bits) +# vlc -c rl0f < rl0f.vlc > rl0f.tab +1s 1,0 +0100s 2,0 +00101s 3,0 +0000110s 4,0 +00100110s 5,0 +00100001s 6,0 +000000101 0,C5 +000000011 0,C3 +000000010 0,C2 +000000001 0,C1 +000000000 0,C0 +011s 1,1 +000110s 2,1 +00100101s 3,1 +000000110 0,C6 +0101s 1,2 +0000100s 2,2 +00111s 1,3 +00100100s 2,3 +00110s 1,4 +000000111 0,C7 +000111s 1,5 +000000100 0,C4 +000101s 1,6 +000100s 1,7 +0000111s 1,8 +0000101s 1,9 +00100111s 1,10 +00100011s 1,11 +00100010s 1,12 +00100000s 1,13 +000001 0,ESC diff --git a/appl/wm/mpeg/rl0n.tab b/appl/wm/mpeg/rl0n.tab new file mode 100644 index 00000000..2820979b --- /dev/null +++ b/appl/wm/mpeg/rl0n.tab @@ -0,0 +1,517 @@ +# vlc -c rl0n +rl0n_size: con 512; +rl0n_bits: con 9; +rl0n_table:= array[] of { + (9, 0,C0), + (9, 0,C1), + (9, 0,C2), + (9, 0,C3), + (9, 0,C4), + (9, 0,C5), + (9, 0,C6), + (9, 0,C7), + (6, 0,ESC), + (6, 0,ESC), + (6, 0,ESC), + (6, 0,ESC), + (6, 0,ESC), + (6, 0,ESC), + (6, 0,ESC), + (6, 0,ESC), + (8, 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), + (7, 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), + (9, 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), + (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, -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), + (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, -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), + (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, -1,1), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (2, 0,EOB), + (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, -1,0), +}; diff --git a/appl/wm/mpeg/rl0n.vlc b/appl/wm/mpeg/rl0n.vlc new file mode 100644 index 00000000..8cd5da23 --- /dev/null +++ b/appl/wm/mpeg/rl0n.vlc @@ -0,0 +1,35 @@ +# Run/Level Next base (first 9 bits) +# vlc -c rl0n < rl0n.vlc > rl0n.tab +11s 1,0 +0100s 2,0 +00101s 3,0 +0000110s 4,0 +00100110s 5,0 +00100001s 6,0 +000000101 0,C5 +000000011 0,C3 +000000010 0,C2 +000000001 0,C1 +000000000 0,C0 +011s 1,1 +000110s 2,1 +00100101s 3,1 +000000110 0,C6 +0101s 1,2 +0000100s 2,2 +00111s 1,3 +00100100s 2,3 +00110s 1,4 +000000111 0,C7 +000111s 1,5 +000000100 0,C4 +000101s 1,6 +000100s 1,7 +0000111s 1,8 +0000101s 1,9 +00100111s 1,10 +00100011s 1,11 +00100010s 1,12 +00100000s 1,13 +10 0,EOB +000001 0,ESC diff --git a/appl/wm/mpeg/scidct.b b/appl/wm/mpeg/scidct.b new file mode 100644 index 00000000..f59c2217 --- /dev/null +++ b/appl/wm/mpeg/scidct.b @@ -0,0 +1,160 @@ +implement IDCT; + +include "sys.m"; +include "mpegio.m"; + +init() +{ +} + +# Scaled integer implementation. +# inverse two dimensional DCT, Chen-Wang algorithm +# (IEEE ASSP-32, pp. 803-816, Aug. 1984) +# 32-bit integer arithmetic (8 bit coefficients) +# 11 mults, 29 adds per DCT +# +# coefficients extended to 12 bit for IEEE1180-1990 +# compliance + +W1: con 2841; # 2048*sqrt(2)*cos(1*pi/16) +W2: con 2676; # 2048*sqrt(2)*cos(2*pi/16) +W3: con 2408; # 2048*sqrt(2)*cos(3*pi/16) +W5: con 1609; # 2048*sqrt(2)*cos(5*pi/16) +W6: con 1108; # 2048*sqrt(2)*cos(6*pi/16) +W7: con 565; # 2048*sqrt(2)*cos(7*pi/16) + +W1pW7: con 3406; # W1+W7 +W1mW7: con 2276; # W1-W7 +W3pW5: con 4017; # W3+W5 +W3mW5: con 799; # W3-W5 +W2pW6: con 3784; # W2+W6 +W2mW6: con 1567; # W2-W6 + +R2: con 181; # 256/sqrt(2) + +idct(b: array of int) +{ + # transform horizontally + for(y:=0; y<8; y++){ + eighty := y<<3; + # if all non-DC components are zero, just propagate the DC term + if(b[eighty+1]==0) + if(b[eighty+2]==0 && b[eighty+3]==0) + if(b[eighty+4]==0 && b[eighty+5]==0) + if(b[eighty+6]==0 && b[eighty+7]==0){ + v := b[eighty]<<3; + b[eighty+0] = v; + b[eighty+1] = v; + b[eighty+2] = v; + b[eighty+3] = v; + b[eighty+4] = v; + b[eighty+5] = v; + b[eighty+6] = v; + b[eighty+7] = v; + continue; + } + # prescale + x0 := (b[eighty+0]<<11)+128; + x1 := b[eighty+4]<<11; + x2 := b[eighty+6]; + x3 := b[eighty+2]; + x4 := b[eighty+1]; + x5 := b[eighty+7]; + x6 := b[eighty+5]; + x7 := b[eighty+3]; + # first stage + x8 := W7*(x4+x5); + x4 = x8 + W1mW7*x4; + x5 = x8 - W1pW7*x5; + x8 = W3*(x6+x7); + x6 = x8 - W3mW5*x6; + x7 = x8 - W3pW5*x7; + # second stage + x8 = x0 + x1; + x0 -= x1; + x1 = W6*(x3+x2); + x2 = x1 - W2pW6*x2; + x3 = x1 + W2mW6*x3; + x1 = x4 + x6; + x4 -= x6; + x6 = x5 + x7; + x5 -= x7; + # third stage + x7 = x8 + x3; + x8 -= x3; + x3 = x0 + x2; + x0 -= x2; + x2 = (R2*(x4+x5)+128)>>8; + x4 = (R2*(x4-x5)+128)>>8; + # fourth stage + b[eighty+0] = (x7+x1)>>8; + b[eighty+1] = (x3+x2)>>8; + b[eighty+2] = (x0+x4)>>8; + b[eighty+3] = (x8+x6)>>8; + b[eighty+4] = (x8-x6)>>8; + b[eighty+5] = (x0-x4)>>8; + b[eighty+6] = (x3-x2)>>8; + b[eighty+7] = (x7-x1)>>8; + } + # transform vertically + for(x:=0; x<8; x++){ + # if all non-DC components are zero, just propagate the DC term + if(b[x+8*1]==0) + if(b[x+8*2]==0 && b[x+8*3]==0) + if(b[x+8*4]==0 && b[x+8*5]==0) + if(b[x+8*6]==0 && b[x+8*7]==0){ + v := (b[x+8*0]+32)>>6; + b[x+8*0] = v; + b[x+8*1] = v; + b[x+8*2] = v; + b[x+8*3] = v; + b[x+8*4] = v; + b[x+8*5] = v; + b[x+8*6] = v; + b[x+8*7] = v; + continue; + } + # prescale + x0 := (b[x+8*0]<<8)+8192; + x1 := b[x+8*4]<<8; + x2 := b[x+8*6]; + x3 := b[x+8*2]; + x4 := b[x+8*1]; + x5 := b[x+8*7]; + x6 := b[x+8*5]; + x7 := b[x+8*3]; + # first stage + x8 := W7*(x4+x5) + 4; + x4 = (x8+W1mW7*x4)>>3; + x5 = (x8-W1pW7*x5)>>3; + x8 = W3*(x6+x7) + 4; + x6 = (x8-W3mW5*x6)>>3; + x7 = (x8-W3pW5*x7)>>3; + # second stage + x8 = x0 + x1; + x0 -= x1; + x1 = W6*(x3+x2) + 4; + x2 = (x1-W2pW6*x2)>>3; + x3 = (x1+W2mW6*x3)>>3; + x1 = x4 + x6; + x4 -= x6; + x6 = x5 + x7; + x5 -= x7; + # third stage + x7 = x8 + x3; + x8 -= x3; + x3 = x0 + x2; + x0 -= x2; + x2 = (R2*(x4+x5)+128)>>8; + x4 = (R2*(x4-x5)+128)>>8; + # fourth stage + b[x+8*0] = (x7+x1)>>14; + b[x+8*1] = (x3+x2)>>14; + b[x+8*2] = (x0+x4)>>14; + b[x+8*3] = (x8+x6)>>14; + b[x+8*4] = (x8-x6)>>14; + b[x+8*5] = (x0-x4)>>14; + b[x+8*6] = (x3-x2)>>14; + b[x+8*7] = (x7-x1)>>14; + } +} diff --git a/appl/wm/mpeg/vlc.b b/appl/wm/mpeg/vlc.b new file mode 100644 index 00000000..96e136e9 --- /dev/null +++ b/appl/wm/mpeg/vlc.b @@ -0,0 +1,213 @@ +implement Vlc; + +include "sys.m"; +include "draw.m"; +include "bufio.m"; + +# +# Construct expanded Vlc (variable length code) tables +# from vlc description files. +# + +sys: Sys; +bufio: Bufio; +Iobuf: import bufio; + +stderr: ref Sys->FD; + +sv: adt +{ + s: int; + v: string; +}; + +s2list: type list of (string, string); +bits, size: int; +table: array of sv; +prog: string; +undef: string = "UNDEF"; +xfixed: int = 0; +complete: int = 0; +paren: int = 0; + +Vlc: module +{ + init: fn(nil: ref Draw->Context, args: list of string); +}; + +init(nil: ref Draw->Context, args: list of string) +{ + sys = load Sys Sys->PATH; + stderr = sys->fildes(2); + sargs := makestr(args); + prog = hd args; + args = tl args; + bufio = load Bufio Bufio->PATH; + if (bufio == nil) { + sys->fprint(stderr, "%s: could not load %s: %r\n", prog, Bufio->PATH); + return; + } + inf := bufio->fopen(sys->fildes(0), Bufio->OREAD); + if (inf == nil) { + sys->fprint(stderr, "%s: fopen stdin failed: %r\n", prog); + return; + } + while (args != nil && len hd args && (a := hd args)[0] == '-') { + flag: + for (x := 1; x < len a; x++) { + case a[x] { + 'c' => + complete = 1; + 'f' => + xfixed = 1; + 'p' => + paren = 1; + 'u' => + if (++x == len a) { + args = tl args; + if (args == nil) + usage(); + undef = hd args; + } else + undef = a[x:]; + break flag; + * => + usage(); + return; + } + } + args = tl args; + } + vlc := "vlc"; + if (args != nil) { + if (tl args != nil) { + usage(); + return; + } + vlc = hd args; + } + il: s2list; + while ((l := inf.gets('\n')) != nil) { + if (l[0] == '#') + continue; + (n, t) := sys->tokenize(l, " \t\n"); + if (n != 2) { + sys->fprint(stderr, "%s: bad input: %s", prog, l); + return; + } + il = (hd t, hd tl t) :: il; + } + (n, nl) := expand(il); + bits = n; + size = 1 << bits; + table = array[size] of sv; + maketable(nl); + printtable(vlc, sargs); +} + +usage() +{ + sys->fprint(stderr, "usage: %s [-cfp] [-u undef] [stem]\n", prog); +} + +makestr(l: list of string): string +{ + s, t: string; + while (l != nil) { + s = s + t + hd l; + t = " "; + l = tl l; + } + return s; +} + +expand(l: s2list): (int, s2list) +{ + nl: s2list; + max := 0; + while (l != nil) { + (bs, val) := hd l; + n := len bs; + if (n > max) + max = n; + if (bs[n - 1] == 's') { + t := bs[:n - 1]; + nl = (t + "0", val) :: (t + "1", "-" + val) :: nl; + } else + nl = (bs, val) :: nl; + l = tl l; + } + return (max, nl); +} + +maketable(l: s2list) +{ + while (l != nil) { + (bs, val) := hd l; + z := len bs; + if (xfixed && z != bits) + error(sys->sprint("string %s too short", bs)); + s := bits - z; + v := value(bs) << s; + n := 1 << s; + for (i := 0; i < n; i++) { + if (table[v].v != nil) + error(sys->sprint("repeat match for %x", v)); + table[v] = (z, val); + v++; + } + l = tl l; + } +} + +value(s: string): int +{ + n := len s; + v := 0; + for (i := 0; i < n; i++) { + case s[i] { + '0' => + v <<= 1; + '1'=> + v = (v << 1) | 1; + * => + error("bad bitstream: " + s); + } + } + return v; +} + +printtable(s, a: string) +{ + sys->print("# %s\n", a); + sys->print("%s_size: con %d;\n", s, size); + sys->print("%s_bits: con %d;\n", s, bits); + sys->print("%s_table:= array[] of {\n", s); + for (i := 0; i < size; i++) { + if (table[i].v != nil) { + if (xfixed) { + if (paren) + sys->print("\t(%s),\n", table[i].v); + else + sys->print("\t%s,\n", table[i].v); + } else + sys->print("\t(%d, %s),\n", table[i].s, table[i].v); + } else if (!complete) { + if (xfixed) { + if (paren) + sys->print("\t(%s),\n", undef); + else + sys->print("\t%s,\n", undef); + } else + sys->print("\t(0, %s),\n", undef); + } else + error(sys->sprint("no match for %x", i)); + } + sys->print("};\n"); +} + +error(s: string) +{ + sys->fprint(stderr, "%s: error: %s\n", prog, s); + exit; +} diff --git a/appl/wm/mpeg/ydc.tab b/appl/wm/mpeg/ydc.tab new file mode 100644 index 00000000..f2dff729 --- /dev/null +++ b/appl/wm/mpeg/ydc.tab @@ -0,0 +1,133 @@ +# vlc ydc +ydc_size: con 128; +ydc_bits: con 7; +ydc_table:= array[] of { + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 1), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (2, 2), + (3, 0), + (3, 0), + (3, 0), + (3, 0), + (3, 0), + (3, 0), + (3, 0), + (3, 0), + (3, 0), + (3, 0), + (3, 0), + (3, 0), + (3, 0), + (3, 0), + (3, 0), + (3, 0), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 3), + (3, 4), + (3, 4), + (3, 4), + (3, 4), + (3, 4), + (3, 4), + (3, 4), + (3, 4), + (3, 4), + (3, 4), + (3, 4), + (3, 4), + (3, 4), + (3, 4), + (3, 4), + (3, 4), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (4, 5), + (5, 6), + (5, 6), + (5, 6), + (5, 6), + (6, 7), + (6, 7), + (7, 8), + (0, UNDEF), +}; diff --git a/appl/wm/mpeg/ydc.vlc b/appl/wm/mpeg/ydc.vlc new file mode 100644 index 00000000..660ce582 --- /dev/null +++ b/appl/wm/mpeg/ydc.vlc @@ -0,0 +1,11 @@ +# Luminance DC +# vlc ydc < ydc.vlc > ydc.tab +100 0 +00 1 +01 2 +101 3 +110 4 +1110 5 +11110 6 +111110 7 +1111110 8 |
