2 |
#define _VLC_CODES_H_ |
#define _VLC_CODES_H_ |
3 |
|
|
4 |
#include "../portab.h" |
#include "../portab.h" |
5 |
|
#include "mbcoding.h" |
6 |
|
|
7 |
#define VLC_ERROR (-1) |
#define VLC_ERROR (-1) |
8 |
|
#define ESCAPE 7167 |
9 |
|
|
10 |
typedef struct |
typedef struct |
11 |
{ |
{ |
12 |
uint32_t code; |
uint32_t code; |
13 |
int8_t len; |
int8_t len; |
14 |
} VLC; |
} |
15 |
|
VLC; |
16 |
|
|
17 |
|
static VLC *DCT3D[2]; |
18 |
|
|
19 |
|
|
20 |
/****************************************************************** |
/****************************************************************** |
348 |
/* rest of coeffs for last = 1. indexing by [run-2] */ |
/* rest of coeffs for last = 1. indexing by [run-2] */ |
349 |
|
|
350 |
static VLC coeff_tab3[40][1] = { |
static VLC coeff_tab3[40][1] = { |
351 |
{0x0e, 6}, {0x0d, 6}, {0x0c, 6}, |
{{0x0e, 6}}, {{0x0d, 6}}, {{0x0c, 6}}, |
352 |
{0x13, 7}, {0x12, 7}, {0x11, 7}, {0x10, 7}, |
{{0x13, 7}}, {{0x12, 7}}, {{0x11, 7}}, {{0x10, 7}}, |
353 |
{0x1a, 8}, {0x19, 8}, {0x18, 8}, {0x17, 8}, |
{{0x1a, 8}}, {{0x19, 8}}, {{0x18, 8}}, {{0x17, 8}}, |
354 |
{0x16, 8}, {0x15, 8}, {0x14, 8}, {0x13, 8}, |
{{0x16, 8}}, {{0x15, 8}}, {{0x14, 8}}, {{0x13, 8}}, |
355 |
{0x18, 9}, {0x17, 9}, {0x16, 9}, {0x15, 9}, |
{{0x18, 9}}, {{0x17, 9}}, {{0x16, 9}}, {{0x15, 9}}, |
356 |
{0x14, 9}, {0x13, 9}, {0x12, 9}, {0x11, 9}, |
{{0x14, 9}}, {{0x13, 9}}, {{0x12, 9}}, {{0x11, 9}}, |
357 |
{0x07, 10}, {0x06, 10}, {0x05, 10}, {0x04, 10}, |
{{0x07, 10}}, {{0x06, 10}}, {{0x05, 10}}, {{0x04, 10}}, |
358 |
{0x24, 11}, {0x25, 11}, {0x26, 11}, {0x27, 11}, |
{{0x24, 11}}, {{0x25, 11}}, {{0x26, 11}}, {{0x27, 11}}, |
359 |
{0x58, 12}, {0x59, 12}, {0x5a, 12}, {0x5b, 12}, |
{{0x58, 12}}, {{0x59, 12}}, {{0x5a, 12}}, {{0x5b, 12}}, |
360 |
{0x5c, 12}, {0x5d, 12}, {0x5e, 12}, {0x5f, 12}, |
{{0x5c, 12}}, {{0x5d, 12}}, {{0x5e, 12}}, {{0x5f, 12}}, |
361 |
{0x00, 0} |
{{0x00, 0}} |
362 |
}; |
}; |
363 |
|
|
364 |
/* New tables for Intra luminance coefficients. Same codewords, |
/* New tables for Intra luminance coefficients. Same codewords, |
451 |
/* Coeffs for last = 0, run = 10 -> 14. Indexed by [run-10] */ |
/* Coeffs for last = 0, run = 10 -> 14. Indexed by [run-10] */ |
452 |
|
|
453 |
static VLC coeff_tab7[5][1] = { |
static VLC coeff_tab7[5][1] = { |
454 |
{0x17, 8}, {0x19, 9}, {0x18, 9}, {0x07, 10}, |
{{0x17, 8}}, {{0x19, 9}}, {{0x18, 9}}, {{0x07, 10}}, |
455 |
{0x58, 12} |
{{0x58, 12}} |
456 |
}; |
}; |
457 |
|
|
458 |
/* Coeffs for last = 1, run = 0. Indexed by [level-1] */ |
/* Coeffs for last = 1, run = 0. Indexed by [level-1] */ |
506 |
/* Coeffs for last = 1, run = 7 -> 20. Indexed by [run-7] */ |
/* Coeffs for last = 1, run = 7 -> 20. Indexed by [run-7] */ |
507 |
|
|
508 |
static VLC coeff_tab10[14][1] = { |
static VLC coeff_tab10[14][1] = { |
509 |
{0x14, 8}, {0x13, 8}, {0x1a, 8}, {0x15, 9}, |
{{0x14, 8}}, {{0x13, 8}}, {{0x1a, 8}}, {{0x15, 9}}, |
510 |
{0x14, 9}, {0x13, 9}, {0x12, 9}, {0x11, 9}, |
{{0x14, 9}}, {{0x13, 9}}, {{0x12, 9}}, {{0x11, 9}}, |
511 |
{0x26, 11}, {0x27, 11}, {0x5c, 12}, {0x5d, 12}, |
{{0x26, 11}}, {{0x27, 11}}, {{0x5c, 12}}, {{0x5d, 12}}, |
512 |
{0x5e, 12}, {0x5f, 12} |
{{0x5e, 12}}, {{0x5f, 12}} |
513 |
}; |
}; |
514 |
|
|
515 |
|
|
637 |
coeff_inter_last1, |
coeff_inter_last1, |
638 |
}; |
}; |
639 |
|
|
640 |
static const VLC mcbpc_I[4] = { |
/* MCBPC Indexing by cbpc in first two bits, mode in last two. |
641 |
{1, 1}, {1, 3}, {2, 3}, {3, 3} |
CBPC as in table 4/H.263, MB type (mode): 3 = 01, 4 = 10. |
642 |
}; |
Example: cbpc = 01 and mode = 4 gives index = 0110 = 6. */ |
643 |
|
|
644 |
static const VLC mcbpc_P_intra[4] = { |
static VLC mcbpc_intra_tab[15] = { |
645 |
{3, 5}, {4, 8}, {3, 8}, {3, 7} |
{0x01, 9}, {0x01, 1}, {0x01, 4}, {0x00, 0}, |
646 |
}; |
{0x00, 0}, {0x01, 3}, {0x01, 6}, {0x00, 0}, |
647 |
|
{0x00, 0}, {0x02, 3}, {0x02, 6}, {0x00, 0}, |
648 |
static const VLC mcbpc_P_inter[4] = { |
{0x00, 0}, {0x03, 3}, {0x03, 6} |
649 |
{1, 1}, {3, 4}, {2, 4}, {5, 6} |
}; |
650 |
}; |
|
651 |
|
/* MCBPC inter. |
652 |
static const VLC mcbpc_P_inter4v[4] = { |
Addressing: 5 bit ccmmm (cc = CBPC, mmm = mode (1-4 binary)) */ |
653 |
{2, 3}, {5, 7}, {4, 7}, {5, 8} |
|
654 |
|
static VLC mcbpc_inter_tab[29] = { |
655 |
|
{1, 1}, {3, 3}, {2, 3}, {3, 5}, {4, 6}, {1, 9}, {0, 0}, {0, 0}, |
656 |
|
{3, 4}, {7, 7}, {5, 7}, {4, 8}, {4, 9}, {0, 0}, {0, 0}, {0, 0}, |
657 |
|
{2, 4}, {6, 7}, {4, 7}, {3, 8}, {3, 9}, {0, 0}, {0, 0}, {0, 0}, |
658 |
|
{5, 6}, {5, 9}, {5, 8}, {3, 7}, {2, 9} |
659 |
}; |
}; |
660 |
|
|
661 |
static const VLC cbpy_tab[16] = { |
static const VLC cbpy_tab[16] = { |
943 |
{0x10, 11}, {0x0e, 11}, {0x0c, 11}, {0x0a, 11}, |
{0x10, 11}, {0x0e, 11}, {0x0c, 11}, {0x0a, 11}, |
944 |
{0x08, 11}, {0x0e, 12}, {0x0c, 12}, {0x0a, 12}, |
{0x08, 11}, {0x0e, 12}, {0x0c, 12}, {0x0a, 12}, |
945 |
{0x08, 12}, {0x06, 12}, {0x04, 12}, {0x06, 13}, |
{0x08, 12}, {0x06, 12}, {0x04, 12}, {0x06, 13}, |
946 |
{0x04, 13}, |
{0x04, 13} |
947 |
}; |
}; |
948 |
|
|
949 |
|
|
964 |
{3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, |
{3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, |
965 |
{3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, |
{3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, |
966 |
{3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, |
{3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, |
967 |
{3, 1}, |
{3, 1} |
968 |
}; |
}; |
969 |
|
|
970 |
|
|
971 |
static const VLC mcbpc_inter_table[257] = { |
static const VLC mcbpc_inter_table[257] = { |
972 |
{VLC_ERROR,0}, |
{VLC_ERROR,0}, |
973 |
{255,9}, {52,9}, {36,9}, {20,9}, {49,9}, {35,8}, {35,8}, {19,8}, {19,8}, |
{255, 9}, {52, 9}, {36, 9}, {20, 9}, {49, 9}, {35, 8}, {35, 8}, {19, 8}, |
974 |
{50,8}, {50,8}, {51,7}, {51,7}, {51,7}, {51,7}, {34,7}, {34,7}, {34,7}, |
{19, 8}, |
975 |
{34,7}, {18,7}, {18,7}, {18,7}, {18,7}, {33,7}, {33,7}, {33,7}, {33,7}, |
{50, 8}, {50, 8}, {51, 7}, {51, 7}, {51, 7}, {51, 7}, {34, 7}, {34, 7}, |
976 |
|
{34, 7}, |
977 |
|
{34, 7}, {18, 7}, {18, 7}, {18, 7}, {18, 7}, {33, 7}, {33, 7}, {33, 7}, |
978 |
|
{33, 7}, |
979 |
{17,7}, {17,7}, {17,7}, {17,7}, {4,6}, {4,6}, {4,6}, {4,6}, {4,6}, |
{17,7}, {17,7}, {17,7}, {17,7}, {4,6}, {4,6}, {4,6}, {4,6}, {4,6}, |
980 |
{4,6}, {4,6}, {4,6}, {48,6}, {48,6}, {48,6}, {48,6}, {48,6}, {48,6}, |
{4, 6}, {4, 6}, {4, 6}, {48, 6}, {48, 6}, {48, 6}, {48, 6}, {48, 6}, {48, |
981 |
|
6}, |
982 |
{48,6}, {48,6}, {3,5}, {3,5}, {3,5}, {3,5}, {3,5}, {3,5}, {3,5}, |
{48,6}, {48,6}, {3,5}, {3,5}, {3,5}, {3,5}, {3,5}, {3,5}, {3,5}, |
983 |
{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}, |
984 |
{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}, |
985 |
{32,4}, {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, |
{32, 4}, |
986 |
{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}, |
987 |
{32,4}, {32,4}, {32,4}, {32,4}, {32,4}, {16,4}, {16,4}, {16,4}, {16,4}, |
{32, 4}, |
988 |
{16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, |
{32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, |
989 |
{16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, |
{32, 4}, |
990 |
{16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, |
{32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {16, 4}, {16, 4}, {16, 4}, |
991 |
|
{16, 4}, |
992 |
|
{16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, |
993 |
|
{16, 4}, |
994 |
|
{16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, |
995 |
|
{16, 4}, |
996 |
|
{16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, |
997 |
|
{16, 4}, |
998 |
{16,4}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, |
{16,4}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, {2,3}, |
999 |
{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}, |
1000 |
{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}, |
1009 |
{1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, |
{1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, |
1010 |
{1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, |
{1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, |
1011 |
{1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, |
{1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, |
1012 |
{1,3}, {1,3}, {1,3}, {0,1}, |
{1, 3}, {1, 3}, {1, 3}, {0, 1} |
1013 |
}; |
}; |
1014 |
|
|
1015 |
static const VLC cbpy_table[64] = |
static const VLC cbpy_table[64] = { |
|
{ |
|
1016 |
{-1,0}, {-1,0}, {6,6}, {9,6}, {8,5}, {8,5}, {4,5}, {4,5}, |
{-1,0}, {-1,0}, {6,6}, {9,6}, {8,5}, {8,5}, {4,5}, {4,5}, |
1017 |
{2,5}, {2,5}, {1,5}, {1,5}, {0,4}, {0,4}, {0,4}, {0,4}, |
{2,5}, {2,5}, {1,5}, {1,5}, {0,4}, {0,4}, {0,4}, {0,4}, |
1018 |
{12,4}, {12,4}, {12,4}, {12,4}, {10,4}, {10,4}, {10,4}, {10,4}, |
{12,4}, {12,4}, {12,4}, {12,4}, {10,4}, {10,4}, {10,4}, {10,4}, |
1021 |
{11,4}, {11,4}, {11,4}, {11,4}, {7,4}, {7,4}, {7,4}, {7,4}, |
{11,4}, {11,4}, {11,4}, {11,4}, {7,4}, {7,4}, {7,4}, {7,4}, |
1022 |
{15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, |
{15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, |
1023 |
{15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, |
{15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, |
1024 |
{15, 2}, {15, 2}, |
{15, 2}, {15, 2} |
1025 |
}; |
}; |
1026 |
|
|
1027 |
|
|
1028 |
VLC TMNMVtab0[] = { |
VLC TMNMVtab0[] = { |
1029 |
{3,4}, {-3,4}, {2,3}, {2,3}, {-2,3}, {-2,3}, {1,2}, {1,2}, {1,2}, {1,2}, |
{3, 4}, {-3, 4}, {2, 3}, {2, 3}, {-2, 3}, {-2, 3}, {1, 2}, {1, 2}, {1, 2}, |
1030 |
|
{1, 2}, |
1031 |
{-1,2}, {-1,2}, {-1,2}, {-1,2} |
{-1,2}, {-1,2}, {-1,2}, {-1,2} |
1032 |
}; |
}; |
1033 |
|
|
1034 |
VLC TMNMVtab1[] = { |
VLC TMNMVtab1[] = { |
1035 |
{12,10}, {-12,10}, {11,10}, {-11,10}, {10,9}, {10,9}, {-10,9}, {-10,9}, |
{12, 10}, {-12, 10}, {11, 10}, {-11, 10}, {10, 9}, {10, 9}, {-10, 9}, {-10, |
1036 |
{9,9}, {9,9}, {-9,9}, {-9,9}, {8,9}, {8,9}, {-8,9}, {-8,9}, {7,7}, {7,7}, |
9}, |
1037 |
{7,7}, {7,7}, {7,7}, {7,7}, {7,7}, {7,7}, {-7,7}, {-7,7}, {-7,7}, {-7,7}, |
{9, 9}, {9, 9}, {-9, 9}, {-9, 9}, {8, 9}, {8, 9}, {-8, 9}, {-8, 9}, {7, 7}, |
1038 |
{-7,7}, {-7,7}, {-7,7}, {-7,7}, {6,7}, {6,7}, {6,7}, {6,7}, {6,7}, {6,7}, |
{7, 7}, |
1039 |
{6,7}, {6,7}, {-6,7}, {-6,7}, {-6,7}, {-6,7}, {-6,7}, {-6,7}, {-6,7}, |
{7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {-7, 7}, {-7, 7}, {-7, 7}, |
1040 |
{-6,7}, {5,7}, {5,7}, {5,7}, {5,7}, {5,7}, {5,7}, {5,7}, {5,7}, {-5,7}, |
{-7, 7}, |
1041 |
{-5,7}, {-5,7}, {-5,7}, {-5,7}, {-5,7}, {-5,7}, {-5,7}, {4,6}, {4,6}, {4,6}, |
{-7, 7}, {-7, 7}, {-7, 7}, {-7, 7}, {6, 7}, {6, 7}, {6, 7}, {6, 7}, {6, 7}, |
1042 |
{4,6}, {4,6}, {4,6}, {4,6}, {4,6}, {4,6}, {4,6}, {4,6}, {4,6}, {4,6}, {4,6}, |
{6, 7}, |
1043 |
{4,6}, {4,6}, {-4,6}, {-4,6}, {-4,6}, {-4,6}, {-4,6}, {-4,6}, {-4,6}, |
{6, 7}, {6, 7}, {-6, 7}, {-6, 7}, {-6, 7}, {-6, 7}, {-6, 7}, {-6, 7}, {-6, |
1044 |
{-4,6}, {-4,6}, {-4,6}, {-4,6}, {-4,6}, {-4,6}, {-4,6}, {-4,6}, {-4,6} |
7}, |
1045 |
|
{-6, 7}, {5, 7}, {5, 7}, {5, 7}, {5, 7}, {5, 7}, {5, 7}, {5, 7}, {5, 7}, |
1046 |
|
{-5, 7}, |
1047 |
|
{-5, 7}, {-5, 7}, {-5, 7}, {-5, 7}, {-5, 7}, {-5, 7}, {-5, 7}, {4, 6}, {4, |
1048 |
|
6}, |
1049 |
|
{4, 6}, |
1050 |
|
{4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, |
1051 |
|
6}, |
1052 |
|
{4, 6}, |
1053 |
|
{4, 6}, {4, 6}, {-4, 6}, {-4, 6}, {-4, 6}, {-4, 6}, {-4, 6}, {-4, 6}, {-4, |
1054 |
|
6}, |
1055 |
|
{-4, 6}, {-4, 6}, {-4, 6}, {-4, 6}, {-4, 6}, {-4, 6}, {-4, 6}, {-4, 6}, |
1056 |
|
{-4, 6} |
1057 |
}; |
}; |
1058 |
|
|
1059 |
VLC TMNMVtab2[] = { |
VLC TMNMVtab2[] = { |
1060 |
{32,12}, {-32,12}, {31,12}, {-31,12}, {30,11}, {30,11}, {-30,11}, {-30,11}, |
{32, 12}, {-32, 12}, {31, 12}, {-31, 12}, {30, 11}, {30, 11}, {-30, 11}, |
1061 |
{29,11}, {29,11}, {-29,11}, {-29,11}, {28,11}, {28,11}, {-28,11}, {-28,11}, |
{-30, 11}, |
1062 |
{27,11}, {27,11}, {-27,11}, {-27,11}, {26,11}, {26,11}, {-26,11}, {-26,11}, |
{29, 11}, {29, 11}, {-29, 11}, {-29, 11}, {28, 11}, {28, 11}, {-28, 11}, |
1063 |
{25,11}, {25,11}, {-25,11}, {-25,11}, {24,10}, {24,10}, {24,10}, {24,10}, |
{-28, 11}, |
1064 |
{-24,10}, {-24,10}, {-24,10}, {-24,10}, {23,10}, {23,10}, {23,10}, {23,10}, |
{27, 11}, {27, 11}, {-27, 11}, {-27, 11}, {26, 11}, {26, 11}, {-26, 11}, |
1065 |
{-23,10}, {-23,10}, {-23,10}, {-23,10}, {22,10}, {22,10}, {22,10}, {22,10}, |
{-26, 11}, |
1066 |
{-22,10}, {-22,10}, {-22,10}, {-22,10}, {21,10}, {21,10}, {21,10}, {21,10}, |
{25, 11}, {25, 11}, {-25, 11}, {-25, 11}, {24, 10}, {24, 10}, {24, 10}, |
1067 |
{-21,10}, {-21,10}, {-21,10}, {-21,10}, {20,10}, {20,10}, {20,10}, {20,10}, |
{24, 10}, |
1068 |
{-20,10}, {-20,10}, {-20,10}, {-20,10}, {19,10}, {19,10}, {19,10}, {19,10}, |
{-24, 10}, {-24, 10}, {-24, 10}, {-24, 10}, {23, 10}, {23, 10}, {23, 10}, |
1069 |
{-19,10}, {-19,10}, {-19,10}, {-19,10}, {18,10}, {18,10}, {18,10}, {18,10}, |
{23, 10}, |
1070 |
{-18,10}, {-18,10}, {-18,10}, {-18,10}, {17,10}, {17,10}, {17,10}, {17,10}, |
{-23, 10}, {-23, 10}, {-23, 10}, {-23, 10}, {22, 10}, {22, 10}, {22, 10}, |
1071 |
{-17,10}, {-17,10}, {-17,10}, {-17,10}, {16,10}, {16,10}, {16,10}, {16,10}, |
{22, 10}, |
1072 |
{-16,10}, {-16,10}, {-16,10}, {-16,10}, {15,10}, {15,10}, {15,10}, {15,10}, |
{-22, 10}, {-22, 10}, {-22, 10}, {-22, 10}, {21, 10}, {21, 10}, {21, 10}, |
1073 |
{-15,10}, {-15,10}, {-15,10}, {-15,10}, {14,10}, {14,10}, {14,10}, {14,10}, |
{21, 10}, |
1074 |
{-14,10}, {-14,10}, {-14,10}, {-14,10}, {13,10}, {13,10}, {13,10}, {13,10}, |
{-21, 10}, {-21, 10}, {-21, 10}, {-21, 10}, {20, 10}, {20, 10}, {20, 10}, |
1075 |
|
{20, 10}, |
1076 |
|
{-20, 10}, {-20, 10}, {-20, 10}, {-20, 10}, {19, 10}, {19, 10}, {19, 10}, |
1077 |
|
{19, 10}, |
1078 |
|
{-19, 10}, {-19, 10}, {-19, 10}, {-19, 10}, {18, 10}, {18, 10}, {18, 10}, |
1079 |
|
{18, 10}, |
1080 |
|
{-18, 10}, {-18, 10}, {-18, 10}, {-18, 10}, {17, 10}, {17, 10}, {17, 10}, |
1081 |
|
{17, 10}, |
1082 |
|
{-17, 10}, {-17, 10}, {-17, 10}, {-17, 10}, {16, 10}, {16, 10}, {16, 10}, |
1083 |
|
{16, 10}, |
1084 |
|
{-16, 10}, {-16, 10}, {-16, 10}, {-16, 10}, {15, 10}, {15, 10}, {15, 10}, |
1085 |
|
{15, 10}, |
1086 |
|
{-15, 10}, {-15, 10}, {-15, 10}, {-15, 10}, {14, 10}, {14, 10}, {14, 10}, |
1087 |
|
{14, 10}, |
1088 |
|
{-14, 10}, {-14, 10}, {-14, 10}, {-14, 10}, {13, 10}, {13, 10}, {13, 10}, |
1089 |
|
{13, 10}, |
1090 |
{-13,10}, {-13,10}, {-13,10}, {-13,10} |
{-13,10}, {-13,10}, {-13,10}, {-13,10} |
1091 |
}; |
}; |
1092 |
|
|
1110 |
{17,3}, {17,3}, {17,3}, {17,3}, {17,3}, {17,3}, |
{17,3}, {17,3}, {17,3}, {17,3}, {17,3}, {17,3}, |
1111 |
{33,4}, {33,4}, {33,4}, {33,4}, {33,4}, {33,4}, |
{33,4}, {33,4}, {33,4}, {33,4}, {33,4}, {33,4}, |
1112 |
{33,4}, {33,4}, {2,4}, {2,4},{2,4},{2,4}, |
{33,4}, {33,4}, {2,4}, {2,4},{2,4},{2,4}, |
1113 |
{2,4}, {2,4},{2,4},{2,4}, |
{2, 4}, {2, 4}, {2, 4}, {2, 4} |
1114 |
}; |
}; |
1115 |
|
|
1116 |
|
|
1130 |
{4241,8}, {4241,8}, {4241,8}, {4241,8}, {225,8}, {225,8}, |
{4241,8}, {4241,8}, {4241,8}, {4241,8}, {225,8}, {225,8}, |
1131 |
{225,8}, {225,8}, {209,8}, {209,8}, {209,8}, {209,8}, |
{225,8}, {225,8}, {209,8}, {209,8}, {209,8}, {209,8}, |
1132 |
{34,8}, {34,8}, {34,8}, {34,8}, {19,8}, {19,8}, |
{34,8}, {34,8}, {34,8}, {34,8}, {19,8}, {19,8}, |
1133 |
{19,8}, {19,8}, {5,8}, {5,8}, {5,8}, {5,8}, |
{19, 8}, {19, 8}, {5, 8}, {5, 8}, {5, 8}, {5, 8} |
1134 |
}; |
}; |
1135 |
|
|
1136 |
VLC DCT3Dtab2[] = { |
VLC DCT3Dtab2[] = { |
1154 |
{7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, |
{7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, |
1155 |
{7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, |
{7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, |
1156 |
{7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, |
{7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, |
1157 |
{7167,7}, }; |
{7167, 7} |
1158 |
|
}; |
1159 |
|
|
1160 |
|
|
1161 |
/* New tables for Intra luminance blocks */ |
/* New tables for Intra luminance blocks */ |
1188 |
{0x00101, 4}, {0x00101, 4}, {0x00101, 4}, {0x00101, 4}, |
{0x00101, 4}, {0x00101, 4}, {0x00101, 4}, {0x00101, 4}, |
1189 |
{0x00101, 4}, {0x00101, 4}, {0x00101, 4}, {0x00101, 4}, |
{0x00101, 4}, {0x00101, 4}, {0x00101, 4}, {0x00101, 4}, |
1190 |
{0x00003, 4}, {0x00003, 4}, {0x00003, 4}, {0x00003, 4}, |
{0x00003, 4}, {0x00003, 4}, {0x00003, 4}, {0x00003, 4}, |
1191 |
{0x00003, 4}, {0x00003, 4}, {0x00003, 4}, {0x00003, 4}, |
{0x00003, 4}, {0x00003, 4}, {0x00003, 4}, {0x00003, 4} |
1192 |
}; |
}; |
1193 |
|
|
1194 |
|
|
1216 |
{0x00104, 8}, {0x00104, 8}, {0x00104, 8}, {0x00104, 8}, |
{0x00104, 8}, {0x00104, 8}, {0x00104, 8}, {0x00104, 8}, |
1217 |
{0x0000c, 8}, {0x0000c, 8}, {0x0000c, 8}, {0x0000c, 8}, |
{0x0000c, 8}, {0x0000c, 8}, {0x0000c, 8}, {0x0000c, 8}, |
1218 |
{0x0000b, 8}, {0x0000b, 8}, {0x0000b, 8}, {0x0000b, 8}, |
{0x0000b, 8}, {0x0000b, 8}, {0x0000b, 8}, {0x0000b, 8}, |
1219 |
{0x0000a, 8}, {0x0000a, 8}, {0x0000a, 8}, {0x0000a, 8}, |
{0x0000a, 8}, {0x0000a, 8}, {0x0000a, 8}, {0x0000a, 8} |
1220 |
}; |
}; |
1221 |
|
|
1222 |
VLC DCT3Dtab5[] = { |
VLC DCT3Dtab5[] = { |
1249 |
{0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, |
{0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, |
1250 |
{0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, |
{0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, |
1251 |
{0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, |
{0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, |
1252 |
{0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, |
{0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7} |
1253 |
}; |
}; |
1254 |
|
|
1255 |
VLC ERRtab[] = { |
VLC ERRtab[] = { |
1257 |
{VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0}, |
{VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0}, |
1258 |
{VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0}, |
{VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0}, |
1259 |
{VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0}, |
{VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0}, |
1260 |
{VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0}, |
{VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0} |
1261 |
}; |
}; |
1262 |
|
|
1263 |
static const VLC dc_lum_tab[] = { |
static const VLC dc_lum_tab[] = { |
1266 |
{2, 2}, {2, 2}, {1, 2}, {1, 2}, |
{2, 2}, {2, 2}, {1, 2}, {1, 2}, |
1267 |
}; |
}; |
1268 |
|
|
1269 |
|
static __inline int |
1270 |
|
get_coeff(Bitstream * bs, |
1271 |
|
int *run, |
1272 |
|
int *last, |
1273 |
|
int intra, |
1274 |
|
int short_video_header) |
1275 |
|
{ |
1276 |
|
|
1277 |
|
uint32_t mode; |
1278 |
|
const VLC *tab; |
1279 |
|
int32_t level; |
1280 |
|
|
1281 |
|
if (short_video_header) // inter-VLCs will be used for both intra and inter blocks |
1282 |
|
intra = 0; |
1283 |
|
|
1284 |
|
tab = &DCT3D[intra][BitstreamShowBits(bs, 12)]; |
1285 |
|
|
1286 |
|
if (tab->code == -1) |
1287 |
|
goto error; |
1288 |
|
|
1289 |
|
BitstreamSkip(bs, tab->len); |
1290 |
|
|
1291 |
|
if (tab->code != ESCAPE) { |
1292 |
|
if (!intra) { |
1293 |
|
*run = (tab->code >> 4) & 255; |
1294 |
|
level = tab->code & 15; |
1295 |
|
*last = (tab->code >> 12) & 1; |
1296 |
|
} else { |
1297 |
|
*run = (tab->code >> 8) & 255; |
1298 |
|
level = tab->code & 255; |
1299 |
|
*last = (tab->code >> 16) & 1; |
1300 |
|
} |
1301 |
|
return BitstreamGetBit(bs) ? -level : level; |
1302 |
|
} |
1303 |
|
|
1304 |
|
if (short_video_header) { |
1305 |
|
// escape mode 4 - H.263 type, only used if short_video_header = 1 |
1306 |
|
*last = BitstreamGetBit(bs); |
1307 |
|
*run = BitstreamGetBits(bs, 6); |
1308 |
|
level = BitstreamGetBits(bs, 8); |
1309 |
|
|
1310 |
|
if (level == 0 || level == 128) |
1311 |
|
DEBUG1("Illegal LEVEL for ESCAPE mode 4:", level); |
1312 |
|
|
1313 |
|
return (level >= 128 ? -(256 - level) : level); |
1314 |
|
} |
1315 |
|
|
1316 |
|
mode = BitstreamShowBits(bs, 2); |
1317 |
|
|
1318 |
|
if (mode < 3) { |
1319 |
|
BitstreamSkip(bs, (mode == 2) ? 2 : 1); |
1320 |
|
|
1321 |
|
tab = &DCT3D[intra][BitstreamShowBits(bs, 12)]; |
1322 |
|
if (tab->code == -1) |
1323 |
|
goto error; |
1324 |
|
|
1325 |
|
BitstreamSkip(bs, tab->len); |
1326 |
|
|
1327 |
|
if (!intra) { |
1328 |
|
*run = (tab->code >> 4) & 255; |
1329 |
|
level = tab->code & 15; |
1330 |
|
*last = (tab->code >> 12) & 1; |
1331 |
|
} else { |
1332 |
|
*run = (tab->code >> 8) & 255; |
1333 |
|
level = tab->code & 255; |
1334 |
|
*last = (tab->code >> 16) & 1; |
1335 |
|
} |
1336 |
|
|
1337 |
|
if (mode < 2) // first escape mode, level is offset |
1338 |
|
level += max_level[*last + (!intra << 1)][*run]; // need to add back the max level |
1339 |
|
else if (mode == 2) // second escape mode, run is offset |
1340 |
|
*run += max_run[*last + (!intra << 1)][level] + 1; |
1341 |
|
|
1342 |
|
return BitstreamGetBit(bs) ? -level : level; |
1343 |
|
} |
1344 |
|
// third escape mode - fixed length codes |
1345 |
|
BitstreamSkip(bs, 2); |
1346 |
|
*last = BitstreamGetBits(bs, 1); |
1347 |
|
*run = BitstreamGetBits(bs, 6); |
1348 |
|
BitstreamSkip(bs, 1); // marker |
1349 |
|
level = BitstreamGetBits(bs, 12); |
1350 |
|
BitstreamSkip(bs, 1); // marker |
1351 |
|
|
1352 |
|
return (level & 0x800) ? (level | (-1 ^ 0xfff)) : level; |
1353 |
|
|
1354 |
|
error: |
1355 |
|
*run = VLC_ERROR; |
1356 |
|
return 0; |
1357 |
|
|
1358 |
|
} |
1359 |
|
|
1360 |
#endif /* _VLC_CODES_H */ |
#endif /* _VLC_CODES_H */ |