[cvs] / xvidcore / src / bitstream / vlc_codes.h Repository:
ViewVC logotype

Diff of /xvidcore/src/bitstream/vlc_codes.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1, Fri Mar 8 02:44:38 2002 UTC revision 1.6.2.1, Sat Nov 2 15:52:31 2002 UTC
# Line 2  Line 2 
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  /******************************************************************  /******************************************************************
21  /* common tables between encoder/decoder                          *   * common tables between encoder/decoder                          *
22  /******************************************************************/   ******************************************************************/
23    
24  /* constants taken from momusys/vm_common/inlcude/max_level.h */  /* constants taken from momusys/vm_common/inlcude/max_level.h */
25  static char max_level[4][64] = {  static char max_level[4][64] = {
# Line 207  Line 212 
212    
213    
214  /******************************************************************  /******************************************************************
215  /* encoder tables                                                 *   * encoder tables                                                 *
216  /******************************************************************/   ******************************************************************/
217    
218    static VLC sprite_trajectory_code[32768];
219    
220    static VLC sprite_trajectory_len[15] = {
221            { 0x00 , 2},
222            { 0x02 , 3}, { 0x03, 3}, { 0x04, 3}, { 0x05, 3}, { 0x06, 3},
223            { 0x0E , 4}, { 0x1E, 5}, { 0x3E, 6}, { 0x7F, 7}, { 0xFE, 8},
224            { 0x1FE, 9}, {0x3FE,10}, {0x7FE,11}, {0xFFE,12} };
225    
226    
227  /* DCT coefficients. Four tables, two for last = 0, two for last = 1.  /* DCT coefficients. Four tables, two for last = 0, two for last = 1.
228     the sign bit must be added afterwards. */     the sign bit must be added afterwards. */
# Line 343  Line 357 
357  /* rest of coeffs for last = 1. indexing by [run-2] */  /* rest of coeffs for last = 1. indexing by [run-2] */
358    
359  static VLC coeff_tab3[40][1] = {  static VLC coeff_tab3[40][1] = {
360      {0x0e, 6}, {0x0d, 6}, {0x0c, 6},          {{0x0e, 6}}, {{0x0d, 6}}, {{0x0c, 6}},
361      {0x13, 7}, {0x12, 7}, {0x11, 7}, {0x10, 7},          {{0x13, 7}}, {{0x12, 7}}, {{0x11, 7}}, {{0x10, 7}},
362      {0x1a, 8}, {0x19, 8}, {0x18, 8}, {0x17, 8},          {{0x1a, 8}}, {{0x19, 8}}, {{0x18, 8}}, {{0x17, 8}},
363      {0x16, 8}, {0x15, 8}, {0x14, 8}, {0x13, 8},          {{0x16, 8}}, {{0x15, 8}}, {{0x14, 8}}, {{0x13, 8}},
364      {0x18, 9}, {0x17, 9}, {0x16, 9}, {0x15, 9},          {{0x18, 9}}, {{0x17, 9}}, {{0x16, 9}}, {{0x15, 9}},
365      {0x14, 9}, {0x13, 9}, {0x12, 9}, {0x11, 9},          {{0x14, 9}}, {{0x13, 9}}, {{0x12, 9}}, {{0x11, 9}},
366      {0x07, 10}, {0x06, 10}, {0x05, 10}, {0x04, 10},          {{0x07, 10}}, {{0x06, 10}}, {{0x05, 10}}, {{0x04, 10}},
367      {0x24, 11}, {0x25, 11}, {0x26, 11}, {0x27, 11},          {{0x24, 11}}, {{0x25, 11}}, {{0x26, 11}}, {{0x27, 11}},
368      {0x58, 12}, {0x59, 12}, {0x5a, 12}, {0x5b, 12},          {{0x58, 12}}, {{0x59, 12}}, {{0x5a, 12}}, {{0x5b, 12}},
369      {0x5c, 12}, {0x5d, 12}, {0x5e, 12}, {0x5f, 12},          {{0x5c, 12}}, {{0x5d, 12}}, {{0x5e, 12}}, {{0x5f, 12}},
370      {0x00, 0}          {{0x00, 0}}
371  };  };
372    
373  /* New tables for Intra luminance coefficients. Same codewords,  /* New tables for Intra luminance coefficients. Same codewords,
# Line 446  Line 460 
460  /* Coeffs for last = 0, run = 10 -> 14. Indexed by [run-10] */  /* Coeffs for last = 0, run = 10 -> 14. Indexed by [run-10] */
461    
462  static VLC coeff_tab7[5][1] = {  static VLC coeff_tab7[5][1] = {
463      {0x17, 8}, {0x19, 9}, {0x18, 9}, {0x07, 10},          {{0x17, 8}}, {{0x19, 9}}, {{0x18, 9}}, {{0x07, 10}},
464      {0x58, 12}          {{0x58, 12}}
465  };  };
466    
467  /* Coeffs for last = 1, run = 0. Indexed by [level-1] */  /* Coeffs for last = 1, run = 0. Indexed by [level-1] */
# Line 501  Line 515 
515  /* Coeffs for last = 1, run = 7 -> 20. Indexed by [run-7] */  /* Coeffs for last = 1, run = 7 -> 20. Indexed by [run-7] */
516    
517  static VLC coeff_tab10[14][1] = {  static VLC coeff_tab10[14][1] = {
518      {0x14, 8}, {0x13, 8}, {0x1a, 8}, {0x15, 9},          {{0x14, 8}}, {{0x13, 8}}, {{0x1a, 8}}, {{0x15, 9}},
519      {0x14, 9}, {0x13, 9}, {0x12, 9}, {0x11, 9},          {{0x14, 9}}, {{0x13, 9}}, {{0x12, 9}}, {{0x11, 9}},
520      {0x26, 11}, {0x27, 11}, {0x5c, 12}, {0x5d, 12},          {{0x26, 11}}, {{0x27, 11}}, {{0x5c, 12}}, {{0x5d, 12}},
521      {0x5e, 12}, {0x5f, 12}          {{0x5e, 12}}, {{0x5f, 12}}
522  };  };
523    
524    
# Line 632  Line 646 
646          coeff_inter_last1,          coeff_inter_last1,
647  };  };
648    
649  static const VLC mcbpc_I[4] = {  /* MCBPC Indexing by cbpc in first two bits, mode in last two.
650          {1, 1}, {1, 3}, {2, 3}, {3, 3}   CBPC as in table 4/H.263, MB type (mode): 3 = 01, 4 = 10.
651  };   Example: cbpc = 01 and mode = 4 gives index = 0110 = 6. */
652    
653  static const VLC mcbpc_P_intra[4] = {  static VLC mcbpc_intra_tab[15] = {
654          {3, 5}, {4, 8}, {3, 8}, {3, 7}          {0x01, 9}, {0x01, 1}, {0x01, 4}, {0x00, 0},
655  };          {0x00, 0}, {0x01, 3}, {0x01, 6}, {0x00, 0},
656            {0x00, 0}, {0x02, 3}, {0x02, 6}, {0x00, 0},
657  static const VLC mcbpc_P_inter[4] = {          {0x00, 0}, {0x03, 3}, {0x03, 6}
658          {1, 1}, {3, 4}, {2, 4}, {5, 6}  };
659  };  
660    /* MCBPC inter.
661  static const VLC mcbpc_P_inter4v[4] = {     Addressing: 5 bit ccmmm (cc = CBPC, mmm = mode (1-4 binary)) */
662          {2, 3}, {5, 7}, {4, 7}, {5, 8}  
663    static VLC mcbpc_inter_tab[29] = {
664            {1, 1}, {3, 3}, {2, 3}, {3, 5}, {4, 6}, {1, 9}, {0, 0}, {0, 0},
665            {3, 4}, {7, 7}, {5, 7}, {4, 8}, {4, 9}, {0, 0}, {0, 0}, {0, 0},
666            {2, 4}, {6, 7}, {4, 7}, {3, 8}, {3, 9}, {0, 0}, {0, 0}, {0, 0},
667            {5, 6}, {5, 9}, {5, 8}, {3, 7}, {2, 9}
668  };  };
669    
670  static const VLC cbpy_tab[16] = {  static const VLC cbpy_tab[16] = {
# Line 933  Line 952 
952  {0x10, 11}, {0x0e, 11}, {0x0c, 11}, {0x0a, 11},  {0x10, 11}, {0x0e, 11}, {0x0c, 11}, {0x0a, 11},
953  {0x08, 11}, {0x0e, 12}, {0x0c, 12}, {0x0a, 12},  {0x08, 11}, {0x0e, 12}, {0x0c, 12}, {0x0a, 12},
954  {0x08, 12}, {0x06, 12}, {0x04, 12}, {0x06, 13},  {0x08, 12}, {0x06, 12}, {0x04, 12}, {0x06, 13},
955  {0x04, 13},          {0x04, 13}
956  };  };
957    
958    
959  /******************************************************************  /******************************************************************
960  /* decoder tables                                                                             *   * decoder tables                                                 *
961  /******************************************************************/   ******************************************************************/
962    
963  static const VLC mcbpc_intra_table[64] = {  static const VLC mcbpc_intra_table[64] = {
964          {-1,0},          {-1,0},
# Line 954  Line 973 
973          {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1},          {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1},
974          {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1},          {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1},
975          {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1},          {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1},
976          {3, 1},          {3, 1}
977  };  };
978    
979    
980  static const VLC mcbpc_inter_table[257] = {  static const VLC mcbpc_inter_table[257] = {
981          {VLC_ERROR,0},          {VLC_ERROR,0},
982          {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},
983          {50,8}, {50,8}, {51,7}, {51,7}, {51,7}, {51,7}, {34,7}, {34,7}, {34,7},                  {19, 8},
984          {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},
985                    {34, 7},
986            {34, 7}, {18, 7}, {18, 7}, {18, 7}, {18, 7}, {33, 7}, {33, 7}, {33, 7},
987                    {33, 7},
988          {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},
989          {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,
990                                                                                                                                                      6},
991          {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},
992          {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},
993          {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},
994          {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, {32,4},                  {32, 4},
995          {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},
996          {32,4}, {32,4}, {32,4}, {32,4}, {32,4}, {16,4}, {16,4}, {16,4}, {16,4},                  {32, 4},
997          {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},
998          {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4}, {16,4},                  {32, 4},
999          {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},
1000                    {16, 4},
1001            {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4},
1002                    {16, 4},
1003            {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4},
1004                    {16, 4},
1005            {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4},
1006                    {16, 4},
1007          {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},
1008          {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          {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},
# Line 988  Line 1018 
1018          {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3},          {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3},
1019          {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3},          {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3},
1020          {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3},          {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3}, {1,3},
1021          {1,3}, {1,3}, {1,3}, {0,1},          {1, 3}, {1, 3}, {1, 3}, {0, 1}
1022  };  };
1023    
1024  static const VLC cbpy_table[64] =  static const VLC cbpy_table[64] = {
 {  
1025          {-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},
1026          {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},
1027    {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},
# Line 1001  Line 1030 
1030    {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},
1031          {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},
1032          {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},
1033          {15, 2}, {15, 2},          {15, 2}, {15, 2}
1034  };  };
1035    
1036    
1037  VLC TMNMVtab0[] = {  VLC TMNMVtab0[] = {
1038  {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},
1039                    {1, 2},
1040  {-1,2}, {-1,2}, {-1,2}, {-1,2}  {-1,2}, {-1,2}, {-1,2}, {-1,2}
1041  };  };
1042    
1043  VLC TMNMVtab1[] = {  VLC TMNMVtab1[] = {
1044  {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,
1045  {9,9}, {9,9}, {-9,9}, {-9,9}, {8,9}, {8,9}, {-8,9}, {-8,9}, {7,7}, {7,7},                                                                                                                                                     9},
1046  {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},
1047  {-7,7}, {-7,7}, {-7,7}, {-7,7}, {6,7}, {6,7}, {6,7}, {6,7}, {6,7}, {6,7},                  {7, 7},
1048  {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},
1049  {-6,7}, {5,7}, {5,7}, {5,7}, {5,7}, {5,7}, {5,7}, {5,7}, {5,7}, {-5,7},                  {-7, 7},
1050  {-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},
1051  {4,6}, {4,6}, {4,6}, {4,6}, {4,6}, {4,6}, {4,6}, {4,6}, {4,6}, {4,6}, {4,6},                  {6, 7},
1052  {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,
1053  {-4,6}, {-4,6}, {-4,6}, {-4,6}, {-4,6}, {-4,6}, {-4,6}, {-4,6}, {-4,6}                                                                                                                                                     7},
1054            {-6, 7}, {5, 7}, {5, 7}, {5, 7}, {5, 7}, {5, 7}, {5, 7}, {5, 7}, {5, 7},
1055                    {-5, 7},
1056            {-5, 7}, {-5, 7}, {-5, 7}, {-5, 7}, {-5, 7}, {-5, 7}, {-5, 7}, {4, 6}, {4,
1057                                                                                                                                                            6},
1058                    {4, 6},
1059            {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4,
1060                                                                                                                                                             6},
1061                    {4, 6},
1062            {4, 6}, {4, 6}, {-4, 6}, {-4, 6}, {-4, 6}, {-4, 6}, {-4, 6}, {-4, 6}, {-4,
1063                                                                                                                                                       6},
1064            {-4, 6}, {-4, 6}, {-4, 6}, {-4, 6}, {-4, 6}, {-4, 6}, {-4, 6}, {-4, 6},
1065                    {-4, 6}
1066  };  };
1067    
1068  VLC TMNMVtab2[] = {  VLC TMNMVtab2[] = {
1069  {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},
1070  {29,11}, {29,11}, {-29,11}, {-29,11}, {28,11}, {28,11}, {-28,11}, {-28,11},                  {-30, 11},
1071  {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},
1072  {25,11}, {25,11}, {-25,11}, {-25,11}, {24,10}, {24,10}, {24,10}, {24,10},                  {-28, 11},
1073  {-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},
1074  {-23,10}, {-23,10}, {-23,10}, {-23,10}, {22,10}, {22,10}, {22,10}, {22,10},                  {-26, 11},
1075  {-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},
1076  {-21,10}, {-21,10}, {-21,10}, {-21,10}, {20,10}, {20,10}, {20,10}, {20,10},                  {24, 10},
1077  {-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},
1078  {-19,10}, {-19,10}, {-19,10}, {-19,10}, {18,10}, {18,10}, {18,10}, {18,10},                  {23, 10},
1079  {-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},
1080  {-17,10}, {-17,10}, {-17,10}, {-17,10}, {16,10}, {16,10}, {16,10}, {16,10},                  {22, 10},
1081  {-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},
1082  {-15,10}, {-15,10}, {-15,10}, {-15,10}, {14,10}, {14,10}, {14,10}, {14,10},                  {21, 10},
1083  {-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},
1084                    {20, 10},
1085            {-20, 10}, {-20, 10}, {-20, 10}, {-20, 10}, {19, 10}, {19, 10}, {19, 10},
1086                    {19, 10},
1087            {-19, 10}, {-19, 10}, {-19, 10}, {-19, 10}, {18, 10}, {18, 10}, {18, 10},
1088                    {18, 10},
1089            {-18, 10}, {-18, 10}, {-18, 10}, {-18, 10}, {17, 10}, {17, 10}, {17, 10},
1090                    {17, 10},
1091            {-17, 10}, {-17, 10}, {-17, 10}, {-17, 10}, {16, 10}, {16, 10}, {16, 10},
1092                    {16, 10},
1093            {-16, 10}, {-16, 10}, {-16, 10}, {-16, 10}, {15, 10}, {15, 10}, {15, 10},
1094                    {15, 10},
1095            {-15, 10}, {-15, 10}, {-15, 10}, {-15, 10}, {14, 10}, {14, 10}, {14, 10},
1096                    {14, 10},
1097            {-14, 10}, {-14, 10}, {-14, 10}, {-14, 10}, {13, 10}, {13, 10}, {13, 10},
1098                    {13, 10},
1099  {-13,10}, {-13,10}, {-13,10}, {-13,10}  {-13,10}, {-13,10}, {-13,10}, {-13,10}
1100  };  };
1101    
# Line 1062  Line 1119 
1119  {17,3}, {17,3}, {17,3}, {17,3}, {17,3}, {17,3},  {17,3}, {17,3}, {17,3}, {17,3}, {17,3}, {17,3},
1120  {33,4}, {33,4}, {33,4}, {33,4}, {33,4}, {33,4},  {33,4}, {33,4}, {33,4}, {33,4}, {33,4}, {33,4},
1121  {33,4}, {33,4}, {2,4}, {2,4},{2,4},{2,4},  {33,4}, {33,4}, {2,4}, {2,4},{2,4},{2,4},
1122  {2,4}, {2,4},{2,4},{2,4},          {2, 4}, {2, 4}, {2, 4}, {2, 4}
1123  };  };
1124    
1125    
# Line 1082  Line 1139 
1139  {4241,8}, {4241,8}, {4241,8}, {4241,8}, {225,8}, {225,8},  {4241,8}, {4241,8}, {4241,8}, {4241,8}, {225,8}, {225,8},
1140  {225,8}, {225,8}, {209,8}, {209,8}, {209,8}, {209,8},  {225,8}, {225,8}, {209,8}, {209,8}, {209,8}, {209,8},
1141  {34,8}, {34,8}, {34,8}, {34,8}, {19,8}, {19,8},  {34,8}, {34,8}, {34,8}, {34,8}, {19,8}, {19,8},
1142  {19,8}, {19,8}, {5,8}, {5,8}, {5,8}, {5,8},          {19, 8}, {19, 8}, {5, 8}, {5, 8}, {5, 8}, {5, 8}
1143  };  };
1144    
1145  VLC DCT3Dtab2[] = {  VLC DCT3Dtab2[] = {
# Line 1106  Line 1163 
1163  {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7},  {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7},
1164  {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7},  {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7},
1165  {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7},  {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7},
1166  {7167,7}, };          {7167, 7}
1167    };
1168    
1169    
1170  /* New tables for Intra luminance blocks */  /* New tables for Intra luminance blocks */
# Line 1139  Line 1197 
1197      {0x00101, 4}, {0x00101, 4}, {0x00101, 4}, {0x00101, 4},      {0x00101, 4}, {0x00101, 4}, {0x00101, 4}, {0x00101, 4},
1198      {0x00101, 4}, {0x00101, 4}, {0x00101, 4}, {0x00101, 4},      {0x00101, 4}, {0x00101, 4}, {0x00101, 4}, {0x00101, 4},
1199      {0x00003, 4}, {0x00003, 4}, {0x00003, 4}, {0x00003, 4},      {0x00003, 4}, {0x00003, 4}, {0x00003, 4}, {0x00003, 4},
1200      {0x00003, 4}, {0x00003, 4}, {0x00003, 4}, {0x00003, 4},          {0x00003, 4}, {0x00003, 4}, {0x00003, 4}, {0x00003, 4}
1201  };  };
1202    
1203    
# Line 1167  Line 1225 
1225      {0x00104, 8}, {0x00104, 8}, {0x00104, 8}, {0x00104, 8},      {0x00104, 8}, {0x00104, 8}, {0x00104, 8}, {0x00104, 8},
1226      {0x0000c, 8}, {0x0000c, 8}, {0x0000c, 8}, {0x0000c, 8},      {0x0000c, 8}, {0x0000c, 8}, {0x0000c, 8}, {0x0000c, 8},
1227      {0x0000b, 8}, {0x0000b, 8}, {0x0000b, 8}, {0x0000b, 8},      {0x0000b, 8}, {0x0000b, 8}, {0x0000b, 8}, {0x0000b, 8},
1228      {0x0000a, 8}, {0x0000a, 8}, {0x0000a, 8}, {0x0000a, 8},          {0x0000a, 8}, {0x0000a, 8}, {0x0000a, 8}, {0x0000a, 8}
1229  };  };
1230    
1231  VLC DCT3Dtab5[] = {  VLC DCT3Dtab5[] = {
# Line 1200  Line 1258 
1258      {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7},      {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7},
1259      {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7},      {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7},
1260      {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7},      {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7},
1261      {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7},          {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}
1262  };  };
1263    
1264  VLC ERRtab[] = {  VLC ERRtab[] = {
# Line 1208  Line 1266 
1266          {VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0},          {VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0},
1267          {VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0},          {VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0},
1268          {VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0},          {VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0},
1269          {VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0},          {VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0}
1270  };  };
1271    
1272  static const VLC dc_lum_tab[] = {  static const VLC dc_lum_tab[] = {
# Line 1217  Line 1275 
1275          {2, 2}, {2, 2}, {1, 2}, {1, 2},          {2, 2}, {2, 2}, {1, 2}, {1, 2},
1276  };  };
1277    
1278    static __inline int
1279    get_coeff(Bitstream * bs,
1280                      int *run,
1281                      int *last,
1282                      int intra,
1283                      int short_video_header)
1284    {
1285    
1286            uint32_t mode;
1287            const VLC *tab;
1288            int32_t level;
1289    
1290            if (short_video_header)         // inter-VLCs will be used for both intra and inter blocks
1291                    intra = 0;
1292    
1293            tab = &DCT3D[intra][BitstreamShowBits(bs, 12)];
1294    
1295            if (tab->code == -1)
1296                    goto error;
1297    
1298            BitstreamSkip(bs, tab->len);
1299    
1300            if (tab->code != ESCAPE) {
1301                    if (!intra) {
1302                            *run = (tab->code >> 4) & 255;
1303                            level = tab->code & 15;
1304                            *last = (tab->code >> 12) & 1;
1305                    } else {
1306                            *run = (tab->code >> 8) & 255;
1307                            level = tab->code & 255;
1308                            *last = (tab->code >> 16) & 1;
1309                    }
1310                    return BitstreamGetBit(bs) ? -level : level;
1311            }
1312    
1313            if (short_video_header) {
1314                    // escape mode 4 - H.263 type, only used if short_video_header = 1
1315                    *last = BitstreamGetBit(bs);
1316                    *run = BitstreamGetBits(bs, 6);
1317                    level = BitstreamGetBits(bs, 8);
1318    
1319                    if (level == 0 || level == 128)
1320                            DEBUG1("Illegal LEVEL for ESCAPE mode 4:", level);
1321    
1322                    return (level >= 128 ? -(256 - level) : level);
1323            }
1324    
1325            mode = BitstreamShowBits(bs, 2);
1326    
1327            if (mode < 3) {
1328                    BitstreamSkip(bs, (mode == 2) ? 2 : 1);
1329    
1330                    tab = &DCT3D[intra][BitstreamShowBits(bs, 12)];
1331                    if (tab->code == -1)
1332                            goto error;
1333    
1334                    BitstreamSkip(bs, tab->len);
1335    
1336                    if (!intra) {
1337                            *run = (tab->code >> 4) & 255;
1338                            level = tab->code & 15;
1339                            *last = (tab->code >> 12) & 1;
1340                    } else {
1341                            *run = (tab->code >> 8) & 255;
1342                            level = tab->code & 255;
1343                            *last = (tab->code >> 16) & 1;
1344                    }
1345    
1346                    if (mode < 2)                   // first escape mode, level is offset
1347                            level += max_level[*last + (!intra << 1)][*run];        // need to add back the max level
1348                    else if (mode == 2)             // second escape mode, run is offset
1349                            *run += max_run[*last + (!intra << 1)][level] + 1;
1350    
1351                    return BitstreamGetBit(bs) ? -level : level;
1352            }
1353            // third escape mode - fixed length codes
1354            BitstreamSkip(bs, 2);
1355            *last = BitstreamGetBits(bs, 1);
1356            *run = BitstreamGetBits(bs, 6);
1357            BitstreamSkip(bs, 1);           // marker
1358            level = BitstreamGetBits(bs, 12);
1359            BitstreamSkip(bs, 1);           // marker
1360    
1361            return (level & 0x800) ? (level | (-1 ^ 0xfff)) : level;
1362    
1363      error:
1364            *run = VLC_ERROR;
1365            return 0;
1366    
1367    }
1368    
1369  #endif /* _VLC_CODES_H */  #endif /* _VLC_CODES_H */

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.6.2.1

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4