13 |
|
|
14 |
|
|
15 |
/****************************************************************** |
/****************************************************************** |
16 |
/* common tables between encoder/decoder * |
* common tables between encoder/decoder * |
17 |
/******************************************************************/ |
******************************************************************/ |
18 |
|
|
19 |
/* constants taken from momusys/vm_common/inlcude/max_level.h */ |
/* constants taken from momusys/vm_common/inlcude/max_level.h */ |
20 |
static char max_level[4][64] = { |
static char max_level[4][64] = { |
207 |
|
|
208 |
|
|
209 |
/****************************************************************** |
/****************************************************************** |
210 |
/* encoder tables * |
* encoder tables * |
211 |
/******************************************************************/ |
******************************************************************/ |
212 |
|
|
213 |
/* DCT coefficients. Four tables, two for last = 0, two for last = 1. |
/* DCT coefficients. Four tables, two for last = 0, two for last = 1. |
214 |
the sign bit must be added afterwards. */ |
the sign bit must be added afterwards. */ |
343 |
/* rest of coeffs for last = 1. indexing by [run-2] */ |
/* rest of coeffs for last = 1. indexing by [run-2] */ |
344 |
|
|
345 |
static VLC coeff_tab3[40][1] = { |
static VLC coeff_tab3[40][1] = { |
346 |
{0x0e, 6}, {0x0d, 6}, {0x0c, 6}, |
{{0x0e, 6}}, {{0x0d, 6}}, {{0x0c, 6}}, |
347 |
{0x13, 7}, {0x12, 7}, {0x11, 7}, {0x10, 7}, |
{{0x13, 7}}, {{0x12, 7}}, {{0x11, 7}}, {{0x10, 7}}, |
348 |
{0x1a, 8}, {0x19, 8}, {0x18, 8}, {0x17, 8}, |
{{0x1a, 8}}, {{0x19, 8}}, {{0x18, 8}}, {{0x17, 8}}, |
349 |
{0x16, 8}, {0x15, 8}, {0x14, 8}, {0x13, 8}, |
{{0x16, 8}}, {{0x15, 8}}, {{0x14, 8}}, {{0x13, 8}}, |
350 |
{0x18, 9}, {0x17, 9}, {0x16, 9}, {0x15, 9}, |
{{0x18, 9}}, {{0x17, 9}}, {{0x16, 9}}, {{0x15, 9}}, |
351 |
{0x14, 9}, {0x13, 9}, {0x12, 9}, {0x11, 9}, |
{{0x14, 9}}, {{0x13, 9}}, {{0x12, 9}}, {{0x11, 9}}, |
352 |
{0x07, 10}, {0x06, 10}, {0x05, 10}, {0x04, 10}, |
{{0x07, 10}}, {{0x06, 10}}, {{0x05, 10}}, {{0x04, 10}}, |
353 |
{0x24, 11}, {0x25, 11}, {0x26, 11}, {0x27, 11}, |
{{0x24, 11}}, {{0x25, 11}}, {{0x26, 11}}, {{0x27, 11}}, |
354 |
{0x58, 12}, {0x59, 12}, {0x5a, 12}, {0x5b, 12}, |
{{0x58, 12}}, {{0x59, 12}}, {{0x5a, 12}}, {{0x5b, 12}}, |
355 |
{0x5c, 12}, {0x5d, 12}, {0x5e, 12}, {0x5f, 12}, |
{{0x5c, 12}}, {{0x5d, 12}}, {{0x5e, 12}}, {{0x5f, 12}}, |
356 |
{0x00, 0} |
{{0x00, 0}} |
357 |
}; |
}; |
358 |
|
|
359 |
/* New tables for Intra luminance coefficients. Same codewords, |
/* New tables for Intra luminance coefficients. Same codewords, |
446 |
/* Coeffs for last = 0, run = 10 -> 14. Indexed by [run-10] */ |
/* Coeffs for last = 0, run = 10 -> 14. Indexed by [run-10] */ |
447 |
|
|
448 |
static VLC coeff_tab7[5][1] = { |
static VLC coeff_tab7[5][1] = { |
449 |
{0x17, 8}, {0x19, 9}, {0x18, 9}, {0x07, 10}, |
{{0x17, 8}}, {{0x19, 9}}, {{0x18, 9}}, {{0x07, 10}}, |
450 |
{0x58, 12} |
{{0x58, 12}} |
451 |
}; |
}; |
452 |
|
|
453 |
/* Coeffs for last = 1, run = 0. Indexed by [level-1] */ |
/* Coeffs for last = 1, run = 0. Indexed by [level-1] */ |
501 |
/* Coeffs for last = 1, run = 7 -> 20. Indexed by [run-7] */ |
/* Coeffs for last = 1, run = 7 -> 20. Indexed by [run-7] */ |
502 |
|
|
503 |
static VLC coeff_tab10[14][1] = { |
static VLC coeff_tab10[14][1] = { |
504 |
{0x14, 8}, {0x13, 8}, {0x1a, 8}, {0x15, 9}, |
{{0x14, 8}}, {{0x13, 8}}, {{0x1a, 8}}, {{0x15, 9}}, |
505 |
{0x14, 9}, {0x13, 9}, {0x12, 9}, {0x11, 9}, |
{{0x14, 9}}, {{0x13, 9}}, {{0x12, 9}}, {{0x11, 9}}, |
506 |
{0x26, 11}, {0x27, 11}, {0x5c, 12}, {0x5d, 12}, |
{{0x26, 11}}, {{0x27, 11}}, {{0x5c, 12}}, {{0x5d, 12}}, |
507 |
{0x5e, 12}, {0x5f, 12} |
{{0x5e, 12}}, {{0x5f, 12}} |
508 |
}; |
}; |
509 |
|
|
510 |
|
|
632 |
coeff_inter_last1, |
coeff_inter_last1, |
633 |
}; |
}; |
634 |
|
|
635 |
static const VLC mcbpc_I[4] = { |
/* MCBPC Indexing by cbpc in first two bits, mode in last two. |
636 |
{1, 1}, {1, 3}, {2, 3}, {3, 3} |
CBPC as in table 4/H.263, MB type (mode): 3 = 01, 4 = 10. |
637 |
}; |
Example: cbpc = 01 and mode = 4 gives index = 0110 = 6. */ |
638 |
|
|
639 |
static const VLC mcbpc_P_intra[4] = { |
static VLC mcbpc_intra_tab[15] = { |
640 |
{3, 5}, {4, 8}, {3, 8}, {3, 7} |
{0x01, 9}, {0x01, 1}, {0x01, 4}, {0x00, 0}, |
641 |
}; |
{0x00, 0}, {0x01, 3}, {0x01, 6}, {0x00, 0}, |
642 |
|
{0x00, 0}, {0x02, 3}, {0x02, 6}, {0x00, 0}, |
643 |
static const VLC mcbpc_P_inter[4] = { |
{0x00, 0}, {0x03, 3}, {0x03, 6} |
644 |
{1, 1}, {3, 4}, {2, 4}, {5, 6} |
}; |
645 |
}; |
|
646 |
|
/* MCBPC inter. |
647 |
static const VLC mcbpc_P_inter4v[4] = { |
Addressing: 5 bit ccmmm (cc = CBPC, mmm = mode (1-4 binary)) */ |
648 |
{2, 3}, {5, 7}, {4, 7}, {5, 8} |
|
649 |
|
static VLC mcbpc_inter_tab[29] = { |
650 |
|
{1, 1}, {3, 3}, {2, 3}, {3, 5}, {4, 6}, {1, 9}, {0, 0}, {0, 0}, |
651 |
|
{3, 4}, {7, 7}, {5, 7}, {4, 8}, {4, 9}, {0, 0}, {0, 0}, {0, 0}, |
652 |
|
{2, 4}, {6, 7}, {4, 7}, {3, 8}, {3, 9}, {0, 0}, {0, 0}, {0, 0}, |
653 |
|
{5, 6}, {5, 9}, {5, 8}, {3, 7}, {2, 9} |
654 |
}; |
}; |
655 |
|
|
656 |
static const VLC cbpy_tab[16] = { |
static const VLC cbpy_tab[16] = { |
938 |
{0x10, 11}, {0x0e, 11}, {0x0c, 11}, {0x0a, 11}, |
{0x10, 11}, {0x0e, 11}, {0x0c, 11}, {0x0a, 11}, |
939 |
{0x08, 11}, {0x0e, 12}, {0x0c, 12}, {0x0a, 12}, |
{0x08, 11}, {0x0e, 12}, {0x0c, 12}, {0x0a, 12}, |
940 |
{0x08, 12}, {0x06, 12}, {0x04, 12}, {0x06, 13}, |
{0x08, 12}, {0x06, 12}, {0x04, 12}, {0x06, 13}, |
941 |
{0x04, 13}, |
{0x04, 13} |
942 |
}; |
}; |
943 |
|
|
944 |
|
|
945 |
/****************************************************************** |
/****************************************************************** |
946 |
/* decoder tables * |
* decoder tables * |
947 |
/******************************************************************/ |
******************************************************************/ |
948 |
|
|
949 |
static const VLC mcbpc_intra_table[64] = { |
static const VLC mcbpc_intra_table[64] = { |
950 |
{-1,0}, |
{-1,0}, |
959 |
{3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, |
{3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, |
960 |
{3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, |
{3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, |
961 |
{3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, |
{3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, |
962 |
{3, 1}, |
{3, 1} |
963 |
}; |
}; |
964 |
|
|
965 |
|
|
993 |
{1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, |
{1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, |
994 |
{1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, |
{1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, |
995 |
{1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, |
{1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, |
996 |
{1,3}, {1,3}, {1,3}, {0,1}, |
{1,3}, {1,3}, {1,3}, {0,1} |
997 |
}; |
}; |
998 |
|
|
999 |
static const VLC cbpy_table[64] = |
static const VLC cbpy_table[64] = |
1006 |
{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}, |
1007 |
{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}, |
1008 |
{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}, |
1009 |
{15, 2}, {15, 2}, |
{15, 2}, {15, 2} |
1010 |
}; |
}; |
1011 |
|
|
1012 |
|
|
1067 |
{17,3}, {17,3}, {17,3}, {17,3}, {17,3}, {17,3}, |
{17,3}, {17,3}, {17,3}, {17,3}, {17,3}, {17,3}, |
1068 |
{33,4}, {33,4}, {33,4}, {33,4}, {33,4}, {33,4}, |
{33,4}, {33,4}, {33,4}, {33,4}, {33,4}, {33,4}, |
1069 |
{33,4}, {33,4}, {2,4}, {2,4},{2,4},{2,4}, |
{33,4}, {33,4}, {2,4}, {2,4},{2,4},{2,4}, |
1070 |
{2,4}, {2,4},{2,4},{2,4}, |
{2,4}, {2,4},{2,4},{2,4} |
1071 |
}; |
}; |
1072 |
|
|
1073 |
|
|
1087 |
{4241,8}, {4241,8}, {4241,8}, {4241,8}, {225,8}, {225,8}, |
{4241,8}, {4241,8}, {4241,8}, {4241,8}, {225,8}, {225,8}, |
1088 |
{225,8}, {225,8}, {209,8}, {209,8}, {209,8}, {209,8}, |
{225,8}, {225,8}, {209,8}, {209,8}, {209,8}, {209,8}, |
1089 |
{34,8}, {34,8}, {34,8}, {34,8}, {19,8}, {19,8}, |
{34,8}, {34,8}, {34,8}, {34,8}, {19,8}, {19,8}, |
1090 |
{19,8}, {19,8}, {5,8}, {5,8}, {5,8}, {5,8}, |
{19,8}, {19,8}, {5,8}, {5,8}, {5,8}, {5,8} |
1091 |
}; |
}; |
1092 |
|
|
1093 |
VLC DCT3Dtab2[] = { |
VLC DCT3Dtab2[] = { |
1111 |
{7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, |
{7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, |
1112 |
{7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, |
{7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, |
1113 |
{7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, |
{7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, |
1114 |
{7167,7}, }; |
{7167,7} |
1115 |
|
}; |
1116 |
|
|
1117 |
|
|
1118 |
/* New tables for Intra luminance blocks */ |
/* New tables for Intra luminance blocks */ |
1145 |
{0x00101, 4}, {0x00101, 4}, {0x00101, 4}, {0x00101, 4}, |
{0x00101, 4}, {0x00101, 4}, {0x00101, 4}, {0x00101, 4}, |
1146 |
{0x00101, 4}, {0x00101, 4}, {0x00101, 4}, {0x00101, 4}, |
{0x00101, 4}, {0x00101, 4}, {0x00101, 4}, {0x00101, 4}, |
1147 |
{0x00003, 4}, {0x00003, 4}, {0x00003, 4}, {0x00003, 4}, |
{0x00003, 4}, {0x00003, 4}, {0x00003, 4}, {0x00003, 4}, |
1148 |
{0x00003, 4}, {0x00003, 4}, {0x00003, 4}, {0x00003, 4}, |
{0x00003, 4}, {0x00003, 4}, {0x00003, 4}, {0x00003, 4} |
1149 |
}; |
}; |
1150 |
|
|
1151 |
|
|
1173 |
{0x00104, 8}, {0x00104, 8}, {0x00104, 8}, {0x00104, 8}, |
{0x00104, 8}, {0x00104, 8}, {0x00104, 8}, {0x00104, 8}, |
1174 |
{0x0000c, 8}, {0x0000c, 8}, {0x0000c, 8}, {0x0000c, 8}, |
{0x0000c, 8}, {0x0000c, 8}, {0x0000c, 8}, {0x0000c, 8}, |
1175 |
{0x0000b, 8}, {0x0000b, 8}, {0x0000b, 8}, {0x0000b, 8}, |
{0x0000b, 8}, {0x0000b, 8}, {0x0000b, 8}, {0x0000b, 8}, |
1176 |
{0x0000a, 8}, {0x0000a, 8}, {0x0000a, 8}, {0x0000a, 8}, |
{0x0000a, 8}, {0x0000a, 8}, {0x0000a, 8}, {0x0000a, 8} |
1177 |
}; |
}; |
1178 |
|
|
1179 |
VLC DCT3Dtab5[] = { |
VLC DCT3Dtab5[] = { |
1206 |
{0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, |
{0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, |
1207 |
{0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, |
{0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, |
1208 |
{0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, |
{0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, |
1209 |
{0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, |
{0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7} |
1210 |
}; |
}; |
1211 |
|
|
1212 |
VLC ERRtab[] = { |
VLC ERRtab[] = { |
1214 |
{VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0}, |
{VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0}, |
1215 |
{VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0}, |
{VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0}, |
1216 |
{VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0}, |
{VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0}, |
1217 |
{VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0}, |
{VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0} |
1218 |
}; |
}; |
1219 |
|
|
1220 |
static const VLC dc_lum_tab[] = { |
static const VLC dc_lum_tab[] = { |