[svn] / branches / release-0_9_1-fixes / xvidcore / src / bitstream / vlc_codes.h Repository:
ViewVC logotype

Diff of /branches/release-0_9_1-fixes/xvidcore/src/bitstream/vlc_codes.h

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

revision 450, Sun Sep 8 13:44:11 2002 UTC revision 603, Sat Oct 19 11:41:12 2002 UTC
# Line 3  Line 3 
3   *  XVID MPEG-4 VIDEO CODEC   *  XVID MPEG-4 VIDEO CODEC
4   *  - Vector Length Coding tables -   *  - Vector Length Coding tables -
5   *   *
6   *  Copyright(C) 2002 Michael Militzer   *  Copyright(C) 2002 Michael Militzer <isibaar@xvid.org>
7   *   *
8   *   *
9   *  This program is an implementation of a part of one or more MPEG-4   *  This program is an implementation of a part of one or more MPEG-4
# Line 29  Line 29 
29   *  along with this program; if not, write to the Free Software   *  along with this program; if not, write to the Free Software
30   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
31   *   *
32   * $Id: vlc_codes.h,v 1.7 2002-09-08 13:44:11 edgomez Exp $   * $Id: vlc_codes.h,v 1.11 2002-10-19 11:41:11 edgomez Exp $
33   *   *
34   ****************************************************************************/   ****************************************************************************/
35    
# Line 61  Line 61 
61   ****************************************************************************/   ****************************************************************************/
62    
63  /* constants taken from momusys/vm_common/inlcude/max_level.h */  /* constants taken from momusys/vm_common/inlcude/max_level.h */
64  static char max_level[4][64] = {  static char const max_level[4][64] = {
65          /* intra, last = 0 */          /* intra, last = 0 */
66          {          {
67           27, 10, 5, 4, 3, 3, 3, 3,           27, 10, 5, 4, 3, 3, 3, 3,
# Line 111  Line 111 
111           }           }
112  };  };
113    
114  static char max_run[4][256] = {  static char const max_run[4][256] = {
115          /* intra, last = 0 */          /* intra, last = 0 */
116          {          {
117           0, 14, 9, 7, 3, 2, 1, 1,           0, 14, 9, 7, 3, 2, 1, 1,
# Line 267  Line 267 
267    
268  /* first part of coeffs for last = 0. Indexed by [run][level-1] */  /* first part of coeffs for last = 0. Indexed by [run][level-1] */
269    
270  static VLC coeff_tab0[2][12] = {  static VLC const coeff_tab0[2][12] = {
271          /* run = 0  */          /* run = 0  */
272          {          {
273                  {0x02, 2},  {0x0f, 4},  {0x15, 6},  {0x17, 7},                  {0x02, 2},  {0x0f, 4},  {0x15, 6},  {0x17, 7},
# Line 285  Line 285 
285    
286  /* rest of coeffs for last = 0. indexing by [run-2][level-1] */  /* rest of coeffs for last = 0. indexing by [run-2][level-1] */
287    
288  static VLC coeff_tab1[25][4] = {  static VLC const coeff_tab1[25][4] = {
289          /* First row is run=2, then each row is run 2 + index */          /* First row is run=2, then each row is run 2 + index */
290          {{0x0e, 4}, {0x1d, 8}, {0x0e, 10}, {0x51, 12}},          {{0x0e, 4}, {0x1d, 8}, {0x0e, 10}, {0x51, 12}},
291          {{0x0d, 5}, {0x23, 9},  {0x0d, 10}, {0x00, 0}},          {{0x0d, 5}, {0x23, 9},  {0x0d, 10}, {0x00, 0}},
# Line 317  Line 317 
317    
318  /* first coeffs of last = 1. indexing by [run][level-1] */  /* first coeffs of last = 1. indexing by [run][level-1] */
319    
320  static VLC coeff_tab2[2][3] = {  static VLC const coeff_tab2[2][3] = {
321          /*  run = 0 */          /*  run = 0 */
322          {{0x07, 4}, {0x19, 9},  {0x05, 11}},          {{0x07, 4}, {0x19, 9},  {0x05, 11}},
323          /* run = 1 */          /* run = 1 */
# Line 326  Line 326 
326    
327  /* rest of coeffs for last = 1. indexing by [run-2] */  /* rest of coeffs for last = 1. indexing by [run-2] */
328    
329  static VLC coeff_tab3[40][1] = {  static VLC const coeff_tab3[40][1] = {
330          {{0x0e, 6}},  {{0x0d, 6}},  {{0x0c, 6}},  {{0x13, 7}},          {{0x0e, 6}},  {{0x0d, 6}},  {{0x0c, 6}},  {{0x13, 7}},
331          {{0x12, 7}},  {{0x11, 7}},  {{0x10, 7}},  {{0x1a, 8}},          {{0x12, 7}},  {{0x11, 7}},  {{0x10, 7}},  {{0x1a, 8}},
332          {{0x19, 8}},  {{0x18, 8}},  {{0x17, 8}},  {{0x16, 8}},          {{0x19, 8}},  {{0x18, 8}},  {{0x17, 8}},  {{0x16, 8}},
# Line 346  Line 346 
346    
347  /* Coeffs for last = 0, run = 0. Indexed by [level-1] */  /* Coeffs for last = 0, run = 0. Indexed by [level-1] */
348    
349  static VLC coeff_tab4[27] = {  static VLC const coeff_tab4[27] = {
350          /* run = 0 */          /* run = 0 */
351          {0x02, 2},  {0x06, 3},  {0x0f, 4},          {0x02, 2},  {0x06, 3},  {0x0f, 4},
352          {0x0d, 5},  {0x0c, 5},  {0x15, 6},          {0x0d, 5},  {0x0c, 5},  {0x15, 6},
# Line 361  Line 361 
361    
362  /* Coeffs for last = 0, run = 1. Indexed by [level-1] */  /* Coeffs for last = 0, run = 1. Indexed by [level-1] */
363    
364  static VLC coeff_tab5[10] = {  static VLC const coeff_tab5[10] = {
365          {0x0e, 4}, {0x14, 6},  {0x16, 7},  {0x1c, 8},  {0x20, 9},          {0x0e, 4}, {0x14, 6},  {0x16, 7},  {0x1c, 8},  {0x20, 9},
366          {0x1f, 9}, {0x0d, 10}, {0x22, 11}, {0x53, 12}, {0x55, 12}          {0x1f, 9}, {0x0d, 10}, {0x22, 11}, {0x53, 12}, {0x55, 12}
367  };  };
# Line 396  Line 396 
396    
397  /* Coeffs for last = 0, run = 10 -> 14. Indexed by [run-10] */  /* Coeffs for last = 0, run = 10 -> 14. Indexed by [run-10] */
398    
399  static VLC coeff_tab7[5][1] = {  static VLC const coeff_tab7[5][1] = {
400          {{0x17, 8}},          {{0x17, 8}},
401          {{0x19, 9}},          {{0x19, 9}},
402          {{0x18, 9}},          {{0x18, 9}},
# Line 406  Line 406 
406    
407  /* Coeffs for last = 1, run = 0. Indexed by [level-1] */  /* Coeffs for last = 1, run = 0. Indexed by [level-1] */
408    
409  static VLC coeff_tab8[8] = {  static VLC const coeff_tab8[8] = {
410          {0x07, 4},  {0x0c, 6},  {0x16, 8},  {0x17, 9},          {0x07, 4},  {0x0c, 6},  {0x16, 8},  {0x17, 9},
411          {0x06, 10}, {0x05, 11}, {0x04, 11}, {0x59, 12}          {0x06, 10}, {0x05, 11}, {0x04, 11}, {0x59, 12}
412  };  };
413    
414  /* Coeffs for last = 1, run = 1 -> 6. Indexed by [run-1][level-1] */  /* Coeffs for last = 1, run = 1 -> 6. Indexed by [run-1][level-1] */
415    
416  static VLC coeff_tab9[6][3] = {  static VLC const coeff_tab9[6][3] = {
417          /* run = 1 */          /* run = 1 */
418          {{0x0f, 6}, {0x16, 9}, {0x05, 10}},          {{0x0f, 6}, {0x16, 9}, {0x05, 10}},
419    
# Line 435  Line 435 
435    
436  /* Coeffs for last = 1, run = 7 -> 20. Indexed by [run-7] */  /* Coeffs for last = 1, run = 7 -> 20. Indexed by [run-7] */
437    
438  static VLC coeff_tab10[14][1] = {  static VLC const coeff_tab10[14][1] = {
439          {{0x14, 8}},          {{0x14, 8}},
440          {{0x13, 8}},          {{0x13, 8}},
441          {{0x1a, 8}},          {{0x1a, 8}},
# Line 453  Line 453 
453  };  };
454    
455    
456  static VLC *coeff_intra_last0[15] = {  static VLC const *coeff_intra_last0[15] = {
457          coeff_tab4,          coeff_tab4,
458          coeff_tab5,          coeff_tab5,
459          coeff_tab6[0],          coeff_tab6[0],
# Line 471  Line 471 
471          coeff_tab7[4]          coeff_tab7[4]
472  };  };
473    
474  static VLC *coeff_intra_last1[21] = {  static VLC const *coeff_intra_last1[21] = {
475          coeff_tab8,          coeff_tab8,
476          coeff_tab9[0],          coeff_tab9[0],
477          coeff_tab9[1],          coeff_tab9[1],
# Line 495  Line 495 
495          coeff_tab10[13],          coeff_tab10[13],
496  };  };
497    
498  static VLC *coeff_inter_last0[27] = {  static VLC const *coeff_inter_last0[27] = {
499          coeff_tab0[0],          coeff_tab0[0],
500          coeff_tab0[1],          coeff_tab0[1],
501          coeff_tab1[0],          coeff_tab1[0],
# Line 525  Line 525 
525          coeff_tab1[24],          coeff_tab1[24],
526  };  };
527    
528  static VLC *coeff_inter_last1[42] = {  static VLC const *coeff_inter_last1[42] = {
529          coeff_tab2[0],          coeff_tab2[0],
530          coeff_tab2[1],          coeff_tab2[1],
531          coeff_tab3[0],          coeff_tab3[0],
# Line 570  Line 570 
570          coeff_tab3[39],          coeff_tab3[39],
571  };  };
572    
573  static VLC **coeff_vlc[4] = {  static VLC const **coeff_vlc[4] = {
574          coeff_intra_last0,          coeff_intra_last0,
575          coeff_intra_last1,          coeff_intra_last1,
576          coeff_inter_last0,          coeff_inter_last0,
# Line 583  Line 583 
583   * Example: cbpc = 01 and mode = 4 gives index = 0110 = 6.   * Example: cbpc = 01 and mode = 4 gives index = 0110 = 6.
584   */   */
585    
586  static VLC mcbpc_intra_tab[15] = {  static VLC const mcbpc_intra_tab[15] = {
587          {0x01, 9}, {0x01, 1}, {0x01, 4}, {0x00, 0},          {0x01, 9}, {0x01, 1}, {0x01, 4}, {0x00, 0},
588          {0x00, 0}, {0x01, 3}, {0x01, 6}, {0x00, 0},          {0x00, 0}, {0x01, 3}, {0x01, 6}, {0x00, 0},
589          {0x00, 0}, {0x02, 3}, {0x02, 6}, {0x00, 0},          {0x00, 0}, {0x02, 3}, {0x02, 6}, {0x00, 0},
# Line 593  Line 593 
593  /* MCBPC inter.  /* MCBPC inter.
594     Addressing: 5 bit ccmmm (cc = CBPC, mmm = mode (1-4 binary)) */     Addressing: 5 bit ccmmm (cc = CBPC, mmm = mode (1-4 binary)) */
595    
596  static VLC mcbpc_inter_tab[29] = {  static VLC const mcbpc_inter_tab[29] = {
597          {1, 1}, {3, 3}, {2, 3}, {3, 5}, {4, 6}, {1, 9}, {0, 0}, {0, 0},          {1, 1}, {3, 3}, {2, 3}, {3, 5}, {4, 6}, {1, 9}, {0, 0}, {0, 0},
598          {3, 4}, {7, 7}, {5, 7}, {4, 8}, {4, 9}, {0, 0}, {0, 0}, {0, 0},          {3, 4}, {7, 7}, {5, 7}, {4, 8}, {4, 9}, {0, 0}, {0, 0}, {0, 0},
599          {2, 4}, {6, 7}, {4, 7}, {3, 8}, {3, 9}, {0, 0}, {0, 0}, {0, 0},          {2, 4}, {6, 7}, {4, 7}, {3, 8}, {3, 9}, {0, 0}, {0, 0}, {0, 0},
600          {5, 6}, {5, 9}, {5, 8}, {3, 7}, {2, 9}          {5, 6}, {5, 9}, {5, 8}, {3, 7}, {2, 9}
601  };  };
602    
603  static const VLC cbpy_tab[16] = {  static VLC const cbpy_tab[16] = {
604          {3, 4}, {5, 5}, {4, 5}, {9, 4}, {3, 5}, {7, 4}, {2, 6}, {11, 4},          {3, 4}, {5, 5}, {4, 5}, {9, 4}, {3, 5}, {7, 4}, {2, 6}, {11, 4},
605          {2, 5}, {3, 6}, {5, 4}, {10, 4}, {4, 4}, {8, 4}, {6, 4}, {3, 2}          {2, 5}, {3, 6}, {5, 4}, {10, 4}, {4, 4}, {8, 4}, {6, 4}, {3, 2}
606  };  };
607    
608  static const VLC dcy_tab[511] = {  static VLC const dcy_tab[511] = {
609          {0x100, 15}, {0x101, 15}, {0x102, 15}, {0x103, 15},          {0x100, 15}, {0x101, 15}, {0x102, 15}, {0x103, 15},
610          {0x104, 15}, {0x105, 15}, {0x106, 15}, {0x107, 15},          {0x104, 15}, {0x105, 15}, {0x106, 15}, {0x107, 15},
611          {0x108, 15}, {0x109, 15}, {0x10a, 15}, {0x10b, 15},          {0x108, 15}, {0x109, 15}, {0x10a, 15}, {0x10b, 15},
# Line 736  Line 736 
736          {0x1fd, 15}, {0x1fe, 15}, {0x1ff, 15},          {0x1fd, 15}, {0x1fe, 15}, {0x1ff, 15},
737  };  };
738    
739  static const VLC dcc_tab[511] = {  static VLC const dcc_tab[511] = {
740          {0x100, 16}, {0x101, 16}, {0x102, 16}, {0x103, 16},          {0x100, 16}, {0x101, 16}, {0x102, 16}, {0x103, 16},
741          {0x104, 16}, {0x105, 16}, {0x106, 16}, {0x107, 16},          {0x104, 16}, {0x105, 16}, {0x106, 16}, {0x107, 16},
742          {0x108, 16}, {0x109, 16}, {0x10a, 16}, {0x10b, 16},          {0x108, 16}, {0x109, 16}, {0x10a, 16}, {0x10b, 16},
# Line 868  Line 868 
868  };  };
869    
870    
871  static const VLC mb_motion_table[65] = {  static VLC const mb_motion_table[65] = {
872          {0x05, 13}, {0x07, 13}, {0x05, 12}, {0x07, 12},          {0x05, 13}, {0x07, 13}, {0x05, 12}, {0x07, 12},
873          {0x09, 12}, {0x0b, 12}, {0x0d, 12}, {0x0f, 12},          {0x09, 12}, {0x0b, 12}, {0x0d, 12}, {0x0f, 12},
874          {0x09, 11}, {0x0b, 11}, {0x0d, 11}, {0x0f, 11},          {0x09, 11}, {0x0b, 11}, {0x0d, 11}, {0x0f, 11},
# Line 893  Line 893 
893   * decoder tables                                                 *   * decoder tables                                                 *
894   ******************************************************************/   ******************************************************************/
895    
896  static const VLC mcbpc_intra_table[64] = {  static VLC const mcbpc_intra_table[64] = {
897          {-1, 0}, {20, 6}, {36, 6}, {52, 6}, {4, 4},  {4, 4},  {4, 4},  {4, 4},          {-1, 0}, {20, 6}, {36, 6}, {52, 6}, {4, 4},  {4, 4},  {4, 4},  {4, 4},
898          {19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3},          {19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3},
899          {35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3},          {35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3},
# Line 905  Line 905 
905  };  };
906    
907    
908  static const VLC mcbpc_inter_table[257] = {  static VLC const mcbpc_inter_table[257] = {
909          {VLC_ERROR, 0}, {255, 9}, {52, 9}, {36, 9}, {20, 9}, {49, 9}, {35, 8}, {35, 8},          {VLC_ERROR, 0}, {255, 9}, {52, 9}, {36, 9}, {20, 9}, {49, 9}, {35, 8}, {35, 8},
910          {19, 8}, {19, 8}, {50, 8}, {50, 8}, {51, 7}, {51, 7}, {51, 7}, {51, 7},          {19, 8}, {19, 8}, {50, 8}, {50, 8}, {51, 7}, {51, 7}, {51, 7}, {51, 7},
911          {34, 7}, {34, 7}, {34, 7}, {34, 7}, {18, 7}, {18, 7}, {18, 7}, {18, 7},          {34, 7}, {34, 7}, {34, 7}, {34, 7}, {18, 7}, {18, 7}, {18, 7}, {18, 7},
# Line 941  Line 941 
941          {0, 1}          {0, 1}
942  };  };
943    
944  static const VLC cbpy_table[64] = {  static VLC const cbpy_table[64] = {
945          {-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},
946          {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},
947          {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 953  Line 953 
953  };  };
954    
955    
956  VLC TMNMVtab0[] = {  static VLC const TMNMVtab0[] = {
957          {3, 4}, {-3, 4}, {2, 3}, {2, 3}, {-2, 3}, {-2, 3}, {1, 2},          {3, 4}, {-3, 4}, {2, 3}, {2, 3}, {-2, 3}, {-2, 3}, {1, 2},
958          {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}
959  };  };
960    
961  VLC TMNMVtab1[] = {  static VLC const TMNMVtab1[] = {
962          {12, 10}, {-12, 10}, {11, 10}, {-11, 10},          {12, 10}, {-12, 10}, {11, 10}, {-11, 10},
963          {10, 9}, {10, 9}, {-10, 9}, {-10, 9},          {10, 9}, {10, 9}, {-10, 9}, {-10, 9},
964          {9, 9}, {9, 9}, {-9, 9}, {-9, 9},          {9, 9}, {9, 9}, {-9, 9}, {-9, 9},
# Line 985  Line 985 
985          {-4, 6}, {-4, 6}, {-4, 6},{-4, 6}          {-4, 6}, {-4, 6}, {-4, 6},{-4, 6}
986  };  };
987    
988  VLC TMNMVtab2[] = {  static VLC const TMNMVtab2[] = {
989          {32, 12}, {-32, 12}, {31, 12}, {-31, 12},          {32, 12}, {-32, 12}, {31, 12}, {-31, 12},
990          {30, 11}, {30, 11}, {-30, 11}, {-30, 11},          {30, 11}, {30, 11}, {-30, 11}, {-30, 11},
991          {29, 11}, {29, 11}, {-29, 11}, {-29, 11},          {29, 11}, {29, 11}, {-29, 11}, {-29, 11},
# Line 1020  Line 1020 
1020  };  };
1021    
1022    
1023  VLC DCT3Dtab0[] = {  static VLC const DCT3Dtab0[] = {
1024          {4225, 7}, {4209, 7}, {4193, 7}, {4177, 7}, {193, 7}, {177, 7},          {4225, 7}, {4209, 7}, {4193, 7}, {4177, 7}, {193, 7}, {177, 7},
1025          {161, 7}, {4, 7}, {4161, 6}, {4161, 6}, {4145, 6}, {4145, 6},          {161, 7}, {4, 7}, {4161, 6}, {4161, 6}, {4145, 6}, {4145, 6},
1026          {4129, 6}, {4129, 6}, {4113, 6}, {4113, 6}, {145, 6}, {145, 6},          {4129, 6}, {4129, 6}, {4113, 6}, {4113, 6}, {145, 6}, {145, 6},
# Line 1043  Line 1043 
1043  };  };
1044    
1045    
1046  VLC DCT3Dtab1[] = {  static VLC const DCT3Dtab1[] = {
1047          {9, 10}, {8, 10}, {4481, 9}, {4481, 9}, {4465, 9}, {4465, 9},          {9, 10}, {8, 10}, {4481, 9}, {4481, 9}, {4465, 9}, {4465, 9},
1048          {4449, 9}, {4449, 9}, {4433, 9}, {4433, 9}, {4417, 9}, {4417, 9},          {4449, 9}, {4449, 9}, {4433, 9}, {4433, 9}, {4417, 9}, {4417, 9},
1049          {4401, 9}, {4401, 9}, {4385, 9}, {4385, 9}, {4369, 9}, {4369, 9},          {4401, 9}, {4401, 9}, {4385, 9}, {4385, 9}, {4369, 9}, {4369, 9},
# Line 1062  Line 1062 
1062          {19, 8}, {19, 8}, {5, 8}, {5, 8}, {5, 8}, {5, 8}          {19, 8}, {19, 8}, {5, 8}, {5, 8}, {5, 8}, {5, 8}
1063  };  };
1064    
1065  VLC DCT3Dtab2[] = {  static VLC const DCT3Dtab2[] = {
1066          {4114, 11}, {4114, 11}, {4099, 11}, {4099, 11}, {11, 11}, {11, 11},          {4114, 11}, {4114, 11}, {4099, 11}, {4099, 11}, {11, 11}, {11, 11},
1067          {10, 11}, {10, 11}, {4545, 10}, {4545, 10}, {4545, 10}, {4545, 10},          {10, 11}, {10, 11}, {4545, 10}, {4545, 10}, {4545, 10}, {4545, 10},
1068          {4529, 10}, {4529, 10}, {4529, 10}, {4529, 10}, {4513, 10}, {4513, 10},          {4529, 10}, {4529, 10}, {4529, 10}, {4529, 10}, {4513, 10}, {4513, 10},
# Line 1089  Line 1089 
1089    
1090  /* New tables for Intra luminance blocks */  /* New tables for Intra luminance blocks */
1091    
1092  VLC DCT3Dtab3[] = {  static VLC const DCT3Dtab3[] = {
1093          {0x10401, 7}, {0x10301, 7}, {0x00601, 7}, {0x10501, 7},          {0x10401, 7}, {0x10301, 7}, {0x00601, 7}, {0x10501, 7},
1094          {0x00701, 7}, {0x00202, 7}, {0x00103, 7}, {0x00009, 7},          {0x00701, 7}, {0x00202, 7}, {0x00103, 7}, {0x00009, 7},
1095          {0x10002, 6}, {0x10002, 6}, {0x00501, 6}, {0x00501, 6},          {0x10002, 6}, {0x10002, 6}, {0x00501, 6}, {0x00501, 6},
# Line 1121  Line 1121 
1121  };  };
1122    
1123    
1124  VLC DCT3Dtab4[] = {  static VLC const DCT3Dtab4[] = {
1125          {0x00012, 10}, {0x00011, 10}, {0x10e01, 9}, {0x10e01, 9},          {0x00012, 10}, {0x00011, 10}, {0x10e01, 9}, {0x10e01, 9},
1126          {0x10d01, 9}, {0x10d01, 9}, {0x10c01, 9}, {0x10c01, 9},          {0x10d01, 9}, {0x10d01, 9}, {0x10c01, 9}, {0x10c01, 9},
1127          {0x10b01, 9}, {0x10b01, 9}, {0x10a01, 9}, {0x10a01, 9},          {0x10b01, 9}, {0x10b01, 9}, {0x10a01, 9}, {0x10a01, 9},
# Line 1148  Line 1148 
1148          {0x0000a, 8}, {0x0000a, 8}, {0x0000a, 8}, {0x0000a, 8}          {0x0000a, 8}, {0x0000a, 8}, {0x0000a, 8}, {0x0000a, 8}
1149  };  };
1150    
1151  VLC DCT3Dtab5[] = {  static VLC const DCT3Dtab5[] = {
1152          {0x10007, 11}, {0x10007, 11}, {0x10006, 11}, {0x10006, 11},          {0x10007, 11}, {0x10007, 11}, {0x10006, 11}, {0x10006, 11},
1153          {0x00016, 11}, {0x00016, 11}, {0x00015, 11}, {0x00015, 11},          {0x00016, 11}, {0x00016, 11}, {0x00015, 11}, {0x00015, 11},
1154          {0x10202, 10}, {0x10202, 10}, {0x10202, 10}, {0x10202, 10},          {0x10202, 10}, {0x10202, 10}, {0x10202, 10}, {0x10202, 10},
# Line 1181  Line 1181 
1181          {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}          {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}
1182  };  };
1183    
1184  VLC ERRtab[] = {  static short const dc_threshold[] = {
1185            26708,   29545,   25120,   28265,   29281,    8313,   29557,   29541,
1186            18208,   21838,   18208,   19536,   29472,   26223,   30580,   29281,
1187             8293,   25956,   26994,   25974,    8292,   29286,   28015,   22560,
1188            18774,    8260,   20557,   18245,    8244,   26664,   29812,   14960,
1189            12079,   30583,   11895,   30328,   25705,   28462,   26482,   29472,
1190            30063,   25458,   29541,    8233,   29505,    8299,   28518,    8306,
1191            26740,    8293,   28531,   29301,   25955,    8307,   28532,   31008,
1192            30063,    8306,   26980,   29811,   26994,   30050,   28532,    2674
1193    };
1194    
1195    
1196    static VLC const ERRtab[] = {
1197          {VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0},          {VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0},
1198          {VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0},          {VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0},
1199          {VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0},          {VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0},
# Line 1189  Line 1201 
1201          {VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0}          {VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0}
1202  };  };
1203    
1204  static const VLC dc_lum_tab[] = {  static VLC const dc_lum_tab[] = {
1205          {0, 0}, {4, 3}, {3, 3}, {0, 3},          {0, 0}, {4, 3}, {3, 3}, {0, 3},
1206          {2, 2}, {2, 2}, {1, 2}, {1, 2},          {2, 2}, {2, 2}, {1, 2}, {1, 2},
1207  };  };
1208    
 static __inline int  
 get_coeff(Bitstream * bs,  
                   int *run,  
                   int *last,  
                   int intra,  
                   int short_video_header)  
 {  
   
         uint32_t mode;  
         const VLC *tab;  
         int32_t level;  
   
         if (short_video_header)         // inter-VLCs will be used for both intra and inter blocks  
                 intra = 0;  
   
         tab = &DCT3D[intra][BitstreamShowBits(bs, 12)];  
   
         if (tab->code == -1)  
                 goto error;  
   
         BitstreamSkip(bs, tab->len);  
   
         if (tab->code != ESCAPE) {  
                 if (!intra) {  
                         *run = (tab->code >> 4) & 255;  
                         level = tab->code & 15;  
                         *last = (tab->code >> 12) & 1;  
                 } else {  
                         *run = (tab->code >> 8) & 255;  
                         level = tab->code & 255;  
                         *last = (tab->code >> 16) & 1;  
                 }  
                 return BitstreamGetBit(bs) ? -level : level;  
         }  
   
         if (short_video_header) {  
                 // escape mode 4 - H.263 type, only used if short_video_header = 1  
                 *last = BitstreamGetBit(bs);  
                 *run = BitstreamGetBits(bs, 6);  
                 level = BitstreamGetBits(bs, 8);  
   
                 if (level == 0 || level == 128)  
                         DEBUG1("Illegal LEVEL for ESCAPE mode 4:", level);  
   
                 return (level >= 128 ? -(256 - level) : level);  
         }  
   
         mode = BitstreamShowBits(bs, 2);  
   
         if (mode < 3) {  
                 BitstreamSkip(bs, (mode == 2) ? 2 : 1);  
   
                 tab = &DCT3D[intra][BitstreamShowBits(bs, 12)];  
                 if (tab->code == -1)  
                         goto error;  
   
                 BitstreamSkip(bs, tab->len);  
   
                 if (!intra) {  
                         *run = (tab->code >> 4) & 255;  
                         level = tab->code & 15;  
                         *last = (tab->code >> 12) & 1;  
                 } else {  
                         *run = (tab->code >> 8) & 255;  
                         level = tab->code & 255;  
                         *last = (tab->code >> 16) & 1;  
                 }  
   
                 if (mode < 2)                   // first escape mode, level is offset  
                         level += max_level[*last + (!intra << 1)][*run];        // need to add back the max level  
                 else if (mode == 2)             // second escape mode, run is offset  
                         *run += max_run[*last + (!intra << 1)][level] + 1;  
   
                 return BitstreamGetBit(bs) ? -level : level;  
         }  
         // third escape mode - fixed length codes  
         BitstreamSkip(bs, 2);  
         *last = BitstreamGetBits(bs, 1);  
         *run = BitstreamGetBits(bs, 6);  
         BitstreamSkip(bs, 1);           // marker  
         level = BitstreamGetBits(bs, 12);  
         BitstreamSkip(bs, 1);           // marker  
   
         return (level & 0x800) ? (level | (-1 ^ 0xfff)) : level;  
   
   error:  
         *run = VLC_ERROR;  
         return 0;  
   
 }  
   
1209  #endif /* _VLC_CODES_H */  #endif /* _VLC_CODES_H */

Legend:
Removed from v.450  
changed lines
  Added in v.603

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