Home | History | Annotate | Download | only in src
      1 /* ------------------------------------------------------------------
      2  * Copyright (C) 1998-2009 PacketVideo
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
     13  * express or implied.
     14  * See the License for the specific language governing permissions
     15  * and limitations under the License.
     16  * -------------------------------------------------------------------
     17  */
     18 /******************************************************************************
     19  *
     20  * This software module was originally developed by
     21  *
     22  * Robert Danielsen (Telenor / ACTS-MoMuSys).
     23  *
     24  * and edited by
     25  *
     26  * Minhua Zhou (HHI / ACTS-MoMuSys).
     27  * Luis Ducla-Soares (IST / ACTS-MoMuSys).
     28  *
     29  * in the course of development of the MPEG-4 Video (ISO/IEC 14496-2) standard.
     30  * This software module is an implementation of a part of one or more MPEG-4
     31  * Video (ISO/IEC 14496-2) tools as specified by the MPEG-4 Video (ISO/IEC
     32  * 14496-2) standard.
     33  *
     34  * ISO/IEC gives users of the MPEG-4 Video (ISO/IEC 14496-2) standard free
     35  * license to this software module or modifications thereof for use in hardware
     36  * or software products claiming conformance to the MPEG-4 Video (ISO/IEC
     37  * 14496-2) standard.
     38  *
     39  * Those intending to use this software module in hardware or software products
     40  * are advised that its use may infringe existing patents. The original
     41  * developer of this software module and his/her company, the subsequent
     42  * editors and their companies, and ISO/IEC have no liability for use of this
     43  * software module or modifications thereof in an implementation. Copyright is
     44  * not released for non MPEG-4 Video (ISO/IEC 14496-2) standard conforming
     45  * products.
     46  *
     47  * ACTS-MoMuSys partners retain full right to use the code for his/her own
     48  * purpose, assign or donate the code to a third party and to inhibit third
     49  * parties from using the code for non MPEG-4 Video (ISO/IEC 14496-2) standard
     50  * conforming products. This copyright notice must be included in all copies or
     51  * derivative works.
     52  *
     53  * Copyright (c) 1997
     54  *
     55  *****************************************************************************/
     56 
     57 
     58 /***********************************************************HeaderBegin*******
     59  *
     60  * File:    vlc.h
     61  *
     62  * Author:  Robert Danielsen
     63  * Created: 07.06.96
     64  *
     65  * Description: vlc tables for encoder
     66  *
     67  * Notes:   Idea taken from MPEG-2 software simulation group
     68  *
     69  * Modified:
     70  *  28.10.96 Robert Danielsen: Added tables for Intra luminance
     71  *          coefficients
     72  *      01.05.97 Luis Ducla-Soares: added VM7.0 Reversible VLC tables (RVLC).
     73  *      13.05.97 Minhua Zhou: added cbpy_tab3,cbpy_tab2
     74  *
     75  ***********************************************************HeaderEnd*********/
     76 
     77 /************************    INCLUDE FILES    ********************************/
     78 
     79 #ifndef _VLC_ENC_TAB_H_
     80 #define _VLC_ENC_TAB_H_
     81 
     82 
     83 #include "mp4def.h"
     84 /* type definitions for variable length code table entries */
     85 
     86 
     87 
     88 static const Int intra_max_level[2][64] =
     89 {
     90     {27, 10,  5,  4,  3,  3,  3,  3,
     91         2,  2,  1,  1,  1,  1,  1,  0,
     92         0,  0,  0,  0,  0,  0,  0,  0,
     93         0,  0,  0,  0,  0,  0,  0,  0,
     94         0,  0,  0,  0,  0,  0,  0,  0,
     95         0,  0,  0,  0,  0,  0,  0,  0,
     96         0,  0,  0,  0,  0,  0,  0,  0,
     97         0,  0,  0,  0,  0,  0,  0,  0,
     98     },
     99 
    100     {8,  3,  2,  2,  2,  2,  2,  1,
    101      1,  1,  1,  1,  1,  1,  1,  1,
    102      1,  1,  1,  1,  1,  0,  0,  0,
    103      0,  0,  0,  0,  0,  0,  0,  0,
    104      0,  0,  0,  0,  0,  0,  0,  0,
    105      0,  0,  0,  0,  0,  0,  0,  0,
    106      0,  0,  0,  0,  0,  0,  0,  0,
    107      0,  0,  0,  0,  0,  0,  0,  0
    108     }
    109 };
    110 
    111 
    112 static const Int inter_max_level[2][64] =
    113 {
    114     {12,  6,  4,  3,  3,  3,  3,  2,
    115         2,  2,  2,  1,  1,  1,  1,  1,
    116         1,  1,  1,  1,  1,  1,  1,  1,
    117         1,  1,  1,  0,  0,  0,  0,  0,
    118         0,  0,  0,  0,  0,  0,  0,  0,
    119         0,  0,  0,  0,  0,  0,  0,  0,
    120         0,  0,  0,  0,  0,  0,  0,  0,
    121         0,  0,  0,  0,  0,  0,  0,  0},
    122 
    123     {3,  2,  1,  1,  1,  1,  1,  1,
    124      1,  1,  1,  1,  1,  1,  1,  1,
    125      1,  1,  1,  1,  1,  1,  1,  1,
    126      1,  1,  1,  1,  1,  1,  1,  1,
    127      1,  1,  1,  1,  1,  1,  1,  1,
    128      1,  0,  0,  0,  0,  0,  0,  0,
    129      0,  0,  0,  0,  0,  0,  0,  0,
    130      0,  0,  0,  0,  0,  0,  0,  0}
    131 };
    132 
    133 
    134 static const Int intra_max_run0[28] = { 999, 14,  9,  7,  3,  2,  1,
    135                                         1,  1,  1,  1,  0,  0,  0,
    136                                         0,  0,  0,  0,  0,  0,  0,
    137                                         0,  0,  0,  0,  0,  0,  0
    138                                       };
    139 
    140 
    141 static const Int intra_max_run1[9] = { 999, 20,  6,
    142                                        1,  0,  0,
    143                                        0,  0,  0
    144                                      };
    145 
    146 static const Int inter_max_run0[13] = { 999,
    147                                         26, 10,  6,  2,  1,  1,
    148                                         0,  0,  0,  0,  0,  0
    149                                       };
    150 
    151 
    152 static const Int inter_max_run1[4] = { 999, 40,  1,  0 };
    153 
    154 
    155 
    156 /* DC prediction sizes */
    157 
    158 static const VLCtable DCtab_lum[13] =
    159 {
    160     {3, 3}, {3, 2}, {2, 2}, {2, 3}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7},
    161     {1, 8}, {1, 9}, {1, 10}, {1, 11}
    162 };
    163 
    164 static const VLCtable DCtab_chrom[13] =
    165 {
    166     {3, 2}, {2, 2}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8},
    167     {1, 9}, {1, 10}, {1, 11}, {1, 12}
    168 };
    169 
    170 /* Motion vectors */
    171 
    172 static const VLCtable mvtab[33] =
    173 {
    174     {1, 1}, {1, 2}, {1, 3}, {1, 4}, {3, 6}, {5, 7}, {4, 7}, {3, 7},
    175     {11, 9}, {10, 9}, {9, 9}, {17, 10}, {16, 10}, {15, 10}, {14, 10}, {13, 10},
    176     {12, 10}, {11, 10}, {10, 10}, {9, 10}, {8, 10}, {7, 10}, {6, 10}, {5, 10},
    177     {4, 10}, {7, 11}, {6, 11}, {5, 11}, {4, 11}, {3, 11}, {2, 11}, {3, 12},
    178     {2, 12}
    179 };
    180 
    181 
    182 /* MCBPC Indexing by cbpc in first two bits, mode in last two.
    183  CBPC as in table 4/H.263, MB type (mode): 3 = 01, 4 = 10.
    184  Example: cbpc = 01 and mode = 4 gives index = 0110 = 6. */
    185 
    186 static const VLCtable mcbpc_intra_tab[15] =
    187 {
    188     {0x01, 9}, {0x01, 1}, {0x01, 4}, {0x00, 0},
    189     {0x00, 0}, {0x01, 3}, {0x01, 6}, {0x00, 0},
    190     {0x00, 0}, {0x02, 3}, {0x02, 6}, {0x00, 0},
    191     {0x00, 0}, {0x03, 3}, {0x03, 6}
    192 };
    193 
    194 
    195 /* MCBPC inter.
    196    Addressing: 5 bit ccmmm (cc = CBPC, mmm = mode (1-4 binary)) */
    197 
    198 static const VLCtable mcbpc_inter_tab[29] =
    199 {
    200     {1, 1}, {3, 3}, {2, 3}, {3, 5}, {4, 6}, {1, 9}, {0, 0}, {0, 0},
    201     {3, 4}, {7, 7}, {5, 7}, {4, 8}, {4, 9}, {0, 0}, {0, 0}, {0, 0},
    202     {2, 4}, {6, 7}, {4, 7}, {3, 8}, {3, 9}, {0, 0}, {0, 0}, {0, 0},
    203     {5, 6}, {5, 9}, {5, 8}, {3, 7}, {2, 9}
    204 };
    205 
    206 
    207 
    208 /* CBPY. Straightforward indexing */
    209 
    210 static const VLCtable cbpy_tab[16] =
    211 {
    212     {3, 4}, {5, 5}, {4, 5}, {9, 4}, {3, 5}, {7, 4}, {2, 6}, {11, 4},
    213     {2, 5}, {3, 6}, {5, 4}, {10, 4}, {4, 4}, {8, 4}, {6, 4}, {3, 2}
    214 };
    215 
    216 static const VLCtable cbpy_tab3[8] =
    217 {
    218     {3, 3}, {1, 6}, {1, 5}, {2, 3}, {2, 5}, {3, 5}, {1, 3}, {1, 1}
    219 };
    220 static const VLCtable cbpy_tab2[4] =
    221 {
    222     {1, 4}, {1, 3}, {1, 2}, {1, 1}
    223 };
    224 
    225 /* DCT coefficients. Four tables, two for last = 0, two for last = 1.
    226    the sign bit must be added afterwards. */
    227 
    228 /* first part of coeffs for last = 0. Indexed by [run][level-1] */
    229 
    230 static const VLCtable coeff_tab0[2][12] =
    231 {
    232     /* run = 0 */
    233     {
    234         {0x02, 2}, {0x0f, 4}, {0x15, 6}, {0x17, 7},
    235         {0x1f, 8}, {0x25, 9}, {0x24, 9}, {0x21, 10},
    236         {0x20, 10}, {0x07, 11}, {0x06, 11}, {0x20, 11}
    237     },
    238     /* run = 1 */
    239     {
    240         {0x06, 3}, {0x14, 6}, {0x1e, 8}, {0x0f, 10},
    241         {0x21, 11}, {0x50, 12}, {0x00, 0}, {0x00, 0},
    242         {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}
    243     }
    244 };
    245 
    246 /* rest of coeffs for last = 0. indexing by [run-2][level-1] */
    247 
    248 static const VLCtable coeff_tab1[25][4] =
    249 {
    250     /* run = 2 */
    251     {
    252         {0x0e, 4}, {0x1d, 8}, {0x0e, 10}, {0x51, 12}
    253     },
    254     /* run = 3 */
    255     {
    256         {0x0d, 5}, {0x23, 9}, {0x0d, 10}, {0x00, 0}
    257     },
    258     /* run = 4-26 */
    259     {
    260         {0x0c, 5}, {0x22, 9}, {0x52, 12}, {0x00, 0}
    261     },
    262     {
    263         {0x0b, 5}, {0x0c, 10}, {0x53, 12}, {0x00, 0}
    264     },
    265     {
    266         {0x13, 6}, {0x0b, 10}, {0x54, 12}, {0x00, 0}
    267     },
    268     {
    269         {0x12, 6}, {0x0a, 10}, {0x00, 0}, {0x00, 0}
    270     },
    271     {
    272         {0x11, 6}, {0x09, 10}, {0x00, 0}, {0x00, 0}
    273     },
    274     {
    275         {0x10, 6}, {0x08, 10}, {0x00, 0}, {0x00, 0}
    276     },
    277     {
    278         {0x16, 7}, {0x55, 12}, {0x00, 0}, {0x00, 0}
    279     },
    280     {
    281         {0x15, 7}, {0x00, 0}, {0x00, 0}, {0x00, 0}
    282     },
    283     {
    284         {0x14, 7}, {0x00, 0}, {0x00, 0}, {0x00, 0}
    285     },
    286     {
    287         {0x1c, 8}, {0x00, 0}, {0x00, 0}, {0x00, 0}
    288     },
    289     {
    290         {0x1b, 8}, {0x00, 0}, {0x00, 0}, {0x00, 0}
    291     },
    292     {
    293         {0x21, 9}, {0x00, 0}, {0x00, 0}, {0x00, 0}
    294     },
    295     {
    296         {0x20, 9}, {0x00, 0}, {0x00, 0}, {0x00, 0}
    297     },
    298     {
    299         {0x1f, 9}, {0x00, 0}, {0x00, 0}, {0x00, 0}
    300     },
    301     {
    302         {0x1e, 9}, {0x00, 0}, {0x00, 0}, {0x00, 0}
    303     },
    304     {
    305         {0x1d, 9}, {0x00, 0}, {0x00, 0}, {0x00, 0}
    306     },
    307     {
    308         {0x1c, 9}, {0x00, 0}, {0x00, 0}, {0x00, 0}
    309     },
    310     {
    311         {0x1b, 9}, {0x00, 0}, {0x00, 0}, {0x00, 0}
    312     },
    313     {
    314         {0x1a, 9}, {0x00, 0}, {0x00, 0}, {0x00, 0}
    315     },
    316     {
    317         {0x22, 11}, {0x00, 0}, {0x00, 0}, {0x00, 0}
    318     },
    319     {
    320         {0x23, 11}, {0x00, 0}, {0x00, 0}, {0x00, 0}
    321     },
    322     {
    323         {0x56, 12}, {0x00, 0}, {0x00, 0}, {0x00, 0}
    324     },
    325     {
    326         {0x57, 12}, {0x00, 0}, {0x00, 0}, {0x00, 0}
    327     }
    328 };
    329 
    330 /* first coeffs of last = 1. indexing by [run][level-1] */
    331 
    332 static const VLCtable coeff_tab2[2][3] =
    333 {
    334     /* run = 0 */
    335     {
    336         {0x07, 4}, {0x19, 9}, {0x05, 11}
    337     },
    338     /* run = 1 */
    339     {
    340         {0x0f, 6}, {0x04, 11}, {0x00, 0}
    341     }
    342 };
    343 
    344 /* rest of coeffs for last = 1. indexing by [run-2] */
    345 
    346 static const VLCtable coeff_tab3[40] =
    347 {
    348     {0x0e, 6}, {0x0d, 6}, {0x0c, 6},
    349     {0x13, 7}, {0x12, 7}, {0x11, 7}, {0x10, 7},
    350     {0x1a, 8}, {0x19, 8}, {0x18, 8}, {0x17, 8},
    351     {0x16, 8}, {0x15, 8}, {0x14, 8}, {0x13, 8},
    352     {0x18, 9}, {0x17, 9}, {0x16, 9}, {0x15, 9},
    353     {0x14, 9}, {0x13, 9}, {0x12, 9}, {0x11, 9},
    354     {0x07, 10}, {0x06, 10}, {0x05, 10}, {0x04, 10},
    355     {0x24, 11}, {0x25, 11}, {0x26, 11}, {0x27, 11},
    356     {0x58, 12}, {0x59, 12}, {0x5a, 12}, {0x5b, 12},
    357     {0x5c, 12}, {0x5d, 12}, {0x5e, 12}, {0x5f, 12},
    358     {0x00, 0}
    359 };
    360 
    361 /* New tables for Intra luminance coefficients. Same codewords,
    362    different meaning */
    363 
    364 /* Coeffs for last = 0, run = 0. Indexed by [level-1] */
    365 
    366 static const VLCtable coeff_tab4[27] =
    367 {
    368     /* run = 0 */
    369     {0x02, 2}, {0x06, 3}, {0x0f, 4}, {0x0d, 5},
    370     {0x0c, 5}, {0x15, 6}, {0x13, 6}, {0x12, 6},
    371     {0x17, 7}, {0x1f, 8}, {0x1e, 8}, {0x1d, 8},
    372     {0x25, 9}, {0x24, 9}, {0x23, 9}, {0x21, 9},
    373     {0x21, 10}, {0x20, 10}, {0x0f, 10}, {0x0e, 10},
    374     {0x07, 11}, {0x06, 11}, {0x20, 11}, {0x21, 11},
    375     {0x50, 12}, {0x51, 12}, {0x52, 12}
    376 };
    377 
    378 /* Coeffs for last = 0, run = 1. Indexed by [level-1] */
    379 
    380 static const VLCtable coeff_tab5[10] =
    381 {
    382     {0x0e, 4}, {0x14, 6}, {0x16, 7}, {0x1c, 8},
    383     {0x20, 9}, {0x1f, 9}, {0x0d, 10}, {0x22, 11},
    384     {0x53, 12}, {0x55, 12}
    385 };
    386 
    387 /* Coeffs for last = 0, run = 2 -> 9. Indexed by [run-2][level-1] */
    388 
    389 static const VLCtable coeff_tab6[8][5] =
    390 {
    391     /* run = 2 */
    392     {
    393         {0x0b, 5}, {0x15, 7}, {0x1e, 9}, {0x0c, 10},
    394         {0x56, 12}
    395     },
    396     /* run = 3 */
    397     {
    398         {0x11, 6}, {0x1b, 8}, {0x1d, 9}, {0x0b, 10},
    399         {0x00, 0}
    400     },
    401     /* run = 4 */
    402     {
    403         {0x10, 6}, {0x22, 9}, {0x0a, 10}, {0x00, 0},
    404         {0x00, 0}
    405     },
    406     /* run = 5 */
    407     {
    408         {0x0d, 6}, {0x1c, 9}, {0x08, 10}, {0x00, 0},
    409         {0x00, 0}
    410     },
    411     /* run = 6 */
    412     {
    413         {0x12, 7}, {0x1b, 9}, {0x54, 12}, {0x00, 0},
    414         {0x00, 0}
    415     },
    416     /* run = 7 */
    417     {
    418         {0x14, 7}, {0x1a, 9}, {0x57, 12}, {0x00, 0},
    419         {0x00, 0}
    420     },
    421     /* run = 8 */
    422     {
    423         {0x19, 8}, {0x09, 10}, {0x00, 0}, {0x00, 0},
    424         {0x00, 0}
    425     },
    426     /* run = 9 */
    427     {
    428         {0x18, 8}, {0x23, 11}, {0x00, 0}, {0x00, 0},
    429         {0x00, 0}
    430     }
    431 };
    432 
    433 /* Coeffs for last = 0, run = 10 -> 14. Indexed by [run-10] */
    434 
    435 static const VLCtable coeff_tab7[5] =
    436 {
    437     {0x17, 8}, {0x19, 9}, {0x18, 9}, {0x07, 10},
    438     {0x58, 12}
    439 };
    440 
    441 /* Coeffs for last = 1, run = 0. Indexed by [level-1] */
    442 
    443 static const VLCtable coeff_tab8[8] =
    444 {
    445     {0x07, 4}, {0x0c, 6}, {0x16, 8}, {0x17, 9},
    446     {0x06, 10}, {0x05, 11}, {0x04, 11}, {0x59, 12}
    447 };
    448 
    449 /* Coeffs for last = 1, run = 1 -> 6. Indexed by [run-1][level-1] */
    450 
    451 static const VLCtable coeff_tab9[6][3] =
    452 {
    453     /* run = 1 */
    454     {
    455         {0x0f, 6}, {0x16, 9}, {0x05, 10}
    456     },
    457     /* run = 2 */
    458     {
    459         {0x0e, 6}, {0x04, 10}, {0x00, 0}
    460     },
    461     /* run = 3 */
    462     {
    463         {0x11, 7}, {0x24, 11}, {0x00, 0}
    464     },
    465     /* run = 4 */
    466     {
    467         {0x10, 7}, {0x25, 11}, {0x00, 0}
    468     },
    469     /* run = 5 */
    470     {
    471         {0x13, 7}, {0x5a, 12}, {0x00, 0}
    472     },
    473     /* run = 6 */
    474     {
    475         {0x15, 8}, {0x5b, 12}, {0x00, 0}
    476     }
    477 };
    478 
    479 /* Coeffs for last = 1, run = 7 -> 20. Indexed by [run-7] */
    480 
    481 static const VLCtable coeff_tab10[14] =
    482 {
    483     {0x14, 8}, {0x13, 8}, {0x1a, 8}, {0x15, 9},
    484     {0x14, 9}, {0x13, 9}, {0x12, 9}, {0x11, 9},
    485     {0x26, 11}, {0x27, 11}, {0x5c, 12}, {0x5d, 12},
    486     {0x5e, 12}, {0x5f, 12}
    487 };
    488 
    489 
    490 #ifndef NO_RVLC
    491 /* RVLC tables */
    492 /* DCT coefficients. Four tables, two for last = 0, two for last = 1.
    493    the sign bit must be added afterwards. */
    494 
    495 /* DCT  coeffs (intra) for last = 0.  */
    496 
    497 /* Indexed by [level-1] */
    498 
    499 static const VLCtable coeff_RVLCtab1[27] =
    500 {
    501     /* run = 0 */
    502     {     0x6,  3},
    503     {     0x7,  3},
    504     {     0xa,  4},
    505     {     0x9,  5},
    506     {    0x14,  6},
    507     {    0x15,  6},
    508     {    0x34,  7},
    509     {    0x74,  8},
    510     {    0x75,  8},
    511     {    0xdd,  9},
    512     {    0xec,  9},
    513     {   0x1ec, 10},
    514     {   0x1ed, 10},
    515     {   0x1f4, 10},
    516     {   0x3ec, 11},
    517     {   0x3ed, 11},
    518     {   0x3f4, 11},
    519     {   0x77d, 12},
    520     {   0x7bc, 12},
    521     {   0xfbd, 13},
    522     {   0xfdc, 13},
    523     {   0x7bd, 12},
    524     {   0xfdd, 13},
    525     {  0x1fbd, 14},
    526     {  0x1fdc, 14},
    527     {  0x1fdd, 14},
    528     {  0x1ffc, 15}
    529 };
    530 
    531 
    532 /* Indexed by [level-1] */
    533 
    534 static const VLCtable coeff_RVLCtab2[13] =
    535 {
    536     /* run = 1 */
    537     {     0x1,  4},
    538     {     0x8,  5},
    539     {    0x2d,  7},
    540     {    0x6c,  8},
    541     {    0x6d,  8},
    542     {    0xdc,  9},
    543     {   0x1dd, 10},
    544     {   0x3dc, 11},
    545     {   0x3dd, 11},
    546     {   0x77c, 12},
    547     {   0xfbc, 13},
    548     {  0x1f7d, 14},
    549     {  0x1fbc, 14}
    550 };
    551 
    552 
    553 /* Indexed by [level-1] */
    554 
    555 static const VLCtable coeff_RVLCtab3[11] =
    556 {
    557     /* run = 2 */
    558 
    559     {     0x4,  5},
    560     {    0x2c,  7},
    561     {    0xbc,  9},
    562     {   0x1dc, 10},
    563     {   0x3bc, 11},
    564     {   0x3bd, 11},
    565     {   0xefd, 13},
    566     {   0xf7c, 13},
    567     {   0xf7d, 13},
    568     {  0x1efd, 14},
    569     {  0x1f7c, 14}
    570 };
    571 
    572 
    573 /* Indexed by [level-1] */
    574 
    575 static const VLCtable coeff_RVLCtab4[9] =
    576 {
    577     /* run = 3 */
    578     {     0x5,  5},
    579     {    0x5c,  8},
    580     {    0xbd,  9},
    581     {   0x37d, 11},
    582     {   0x6fc, 12},
    583     {   0xefc, 13},
    584     {  0x1dfd, 14},
    585     {  0x1efc, 14},
    586     {  0x1ffd, 15}
    587 };
    588 
    589 
    590 /* Indexed by [run-4][level-1] */
    591 
    592 static const VLCtable coeff_RVLCtab5[2][6] =
    593 {
    594     /* run = 4 */
    595     {
    596         {     0xc,  6},
    597         {    0x5d,  8},
    598         {   0x1bd, 10},
    599         {   0x3fd, 12},
    600         {   0x6fd, 12},
    601         {  0x1bfd, 14}
    602     },
    603     /* run = 5 */
    604     {
    605         {     0xd,  6},
    606         {    0x7d,  9},
    607         {   0x2fc, 11},
    608         {   0x5fc, 12},
    609         {  0x1bfc, 14},
    610         {  0x1dfc, 14}
    611     }
    612 };
    613 
    614 
    615 /* Indexed by [run-6][level-1]       */
    616 
    617 static const VLCtable coeff_RVLCtab6[2][5] =
    618 {
    619 
    620     /* run = 6 */
    621     {
    622         {    0x1c,  7},
    623         {   0x17c, 10},
    624         {   0x2fd, 11},
    625         {   0x5fd, 12},
    626         {  0x2ffc, 15}
    627     },
    628     /* run = 7 */
    629     {
    630         {    0x1d,  7},
    631         {   0x17d, 10},
    632         {   0x37c, 11},
    633         {   0xdfd, 13},
    634         {  0x2ffd, 15}
    635     }
    636 
    637 };
    638 /* Indexed by [run-8][level-1] */
    639 
    640 static const VLCtable coeff_RVLCtab7[2][4] =
    641 {
    642     /* run = 8 */
    643     {
    644         {    0x3c,  8},
    645         {   0x1bc, 10},
    646         {   0xbfd, 13},
    647         {  0x17fd, 14}
    648     },
    649     /* run = 9 */
    650     {
    651         {    0x3d,  8},
    652         {   0x1fd, 11},
    653         {   0xdfc, 13},
    654         {  0x37fc, 15},
    655     }
    656 };
    657 
    658 
    659 
    660 /* Indexed by [run-10][level-1] */
    661 
    662 static const VLCtable coeff_RVLCtab8[3][2] =
    663 {
    664     /* run = 10 */
    665     {
    666         {    0x7c,  9},
    667         {   0x3fc, 12}
    668     },
    669     /* run = 11 */
    670     {
    671         {    0xfc, 10},
    672         {   0xbfc, 13}
    673     },
    674     /* run = 12 */
    675     {
    676         {    0xfd, 10},
    677         {  0x37fd, 15}
    678     }
    679 };
    680 
    681 
    682 /* Indexed by [level-1] */
    683 
    684 static const VLCtable coeff_RVLCtab9[7] =
    685 {
    686     /* run = 13 -> 19 */
    687     {   0x1fc, 11},
    688     {   0x7fc, 13},
    689     {   0x7fd, 13},
    690     {   0xffc, 14},
    691     {   0xffd, 14},
    692     {  0x17fc, 14},
    693     {  0x3bfc, 15}
    694 };
    695 
    696 
    697 
    698 /* first coeffs of last = 1. indexing by [run][level-1] */
    699 
    700 static const VLCtable coeff_RVLCtab10[2][5] =
    701 {
    702     /* run = 0 */
    703     {
    704         {     0xb,  4},
    705         {    0x78,  8},
    706         {   0x3f5, 11},
    707         {   0xfec, 13},
    708         {  0x1fec, 14}
    709     },
    710     /* run = 1 */
    711     {
    712         {    0x12,  5},
    713         {    0xed,  9},
    714         {   0x7dc, 12},
    715         {  0x1fed, 14},
    716         {  0x3bfd, 15}
    717     }
    718 
    719 };
    720 
    721 static const VLCtable coeff_RVLCtab11[3] =
    722 {
    723     /* run = 2 */
    724     {    0x13,  5},
    725     {   0x3f8, 11},
    726     {  0x3dfc, 15}
    727 
    728 };
    729 
    730 static const VLCtable coeff_RVLCtab12[11][2] =
    731 {
    732     /* run = 3 */
    733     {
    734         {    0x18,  6},
    735         {   0x7dd, 12}
    736     },
    737     /* run = 4 */
    738     {
    739         {    0x19,  6},
    740         {   0x7ec, 12}
    741     },
    742     /* run = 5 */
    743     {
    744         {    0x22,  6},
    745         {   0xfed, 13}
    746     },
    747     /* run = 6 */
    748     {
    749         {    0x23,  6},
    750         {   0xff4, 13}
    751     },
    752     /* run = 7 */
    753     {
    754         {    0x35,  7},
    755         {   0xff5, 13}
    756     },
    757     /* run = 8 */
    758     {
    759         {    0x38,  7},
    760         {   0xff8, 13}
    761     },
    762     /* run = 9 */
    763     {
    764         {    0x39,  7},
    765         {   0xff9, 13}
    766     },
    767     /* run = 10 */
    768     {
    769         {    0x42,  7},
    770         {  0x1ff4, 14}
    771     },
    772     /* run = 11 */
    773     {
    774         {    0x43,  7},
    775         {  0x1ff5, 14}
    776     },
    777     /* run = 12 */
    778     {
    779         {    0x79,  8},
    780         {  0x1ff8, 14}
    781     },
    782     /* run = 13 */
    783     {
    784         {    0x82,  8},
    785         {  0x3dfd, 15}
    786     }
    787 
    788 };
    789 
    790 static const VLCtable coeff_RVLCtab13[32] =
    791 {
    792     /* run = 14 -> 44 */
    793     {    0x83,  8},
    794     {    0xf4,  9},
    795     {    0xf5,  9},
    796     {    0xf8,  9},
    797     {    0xf9,  9},
    798     {   0x102,  9},
    799     {   0x103,  9},
    800     {   0x1f5, 10},
    801     {   0x1f8, 10},
    802     {   0x1f9, 10},
    803     {   0x202, 10},
    804     {   0x203, 10},
    805     {   0x3f9, 11},
    806     {   0x402, 11},
    807     {   0x403, 11},
    808     {   0x7ed, 12},
    809     {   0x7f4, 12},
    810     {   0x7f5, 12},
    811     {   0x7f8, 12},
    812     {   0x7f9, 12},
    813     {   0x802, 12},
    814     {   0x803, 12},
    815     {  0x1002, 13},
    816     {  0x1003, 13},
    817     {  0x1ff9, 14},
    818     {  0x2002, 14},
    819     {  0x2003, 14},
    820     {  0x3efc, 15},
    821     {  0x3efd, 15},
    822     {  0x3f7c, 15},
    823     {  0x3f7d, 15}
    824 };
    825 
    826 
    827 
    828 /* Coeffs for last = 0, run = 0. Indexed by [level-1] */
    829 
    830 static const VLCtable coeff_RVLCtab14[19] =
    831 {
    832     /* run = 0 */
    833     {     0x6,  3},
    834     {     0x1,  4},
    835     {     0x4,  5},
    836     {    0x1c,  7},
    837     {    0x3c,  8},
    838     {    0x3d,  8},
    839     {    0x7c,  9},
    840     {    0xfc, 10},
    841     {    0xfd, 10},
    842     {   0x1fc, 11},
    843     {   0x1fd, 11},
    844     {   0x3fc, 12},
    845     {   0x7fc, 13},
    846     {   0x7fd, 13},
    847     {   0xbfc, 13},
    848     {   0xbfd, 13},
    849     {   0xffc, 14},
    850     {   0xffd, 14},
    851     {  0x1ffc, 15}
    852 };
    853 
    854 static const VLCtable coeff_RVLCtab15[10] =
    855 {
    856     /* run = 1 */
    857     {     0x7,  3},
    858     {     0xc,  6},
    859     {    0x5c,  8},
    860     {    0x7d,  9},
    861     {   0x17c, 10},
    862     {   0x2fc, 11},
    863     {   0x3fd, 12},
    864     {   0xdfc, 13},
    865     {  0x17fc, 14},
    866     {  0x17fd, 14}
    867 };
    868 
    869 static const VLCtable coeff_RVLCtab16[2][7] =
    870 {
    871     /* run = 2 */
    872     {
    873         {     0xa,  4},
    874         {    0x1d,  7},
    875         {    0xbc,  9},
    876         {   0x2fd, 11},
    877         {   0x5fc, 12},
    878         {  0x1bfc, 14},
    879         {  0x1bfd, 14}
    880     },
    881     /* run = 3 */
    882     {
    883         {     0x5,  5},
    884         {    0x5d,  8},
    885         {   0x17d, 10},
    886         {   0x5fd, 12},
    887         {   0xdfd, 13},
    888         {  0x1dfc, 14},
    889         {  0x1ffd, 15}
    890     }
    891 };
    892 
    893 static const VLCtable coeff_RVLCtab17[5] =
    894 {
    895     /* run = 4 */
    896     {     0x8,  5},
    897     {    0x6c,  8},
    898     {   0x37c, 11},
    899     {   0xefc, 13},
    900     {  0x2ffc, 15}
    901 };
    902 
    903 static const VLCtable coeff_RVLCtab18[3][4] =
    904 {
    905     /* run = 5 */
    906     {
    907         {     0x9,  5},
    908         {    0xbd,  9},
    909         {   0x37d, 11},
    910         {   0xefd, 13}
    911     },
    912     /* run = 6 */
    913     {
    914         {     0xd,  6},
    915         {   0x1bc, 10},
    916         {   0x6fc, 12},
    917         {  0x1dfd, 14}
    918     },
    919     /* run = 7 */
    920     {
    921         {    0x14,  6},
    922         {   0x1bd, 10},
    923         {   0x6fd, 12},
    924         {  0x2ffd, 15}
    925     }
    926 };
    927 
    928 static const VLCtable coeff_RVLCtab19[2][3] =
    929 {
    930     /* run = 8 */
    931     {
    932         {    0x15,  6},
    933         {   0x1dc, 10},
    934         {   0xf7c, 13}
    935     },
    936     /* run = 9 */
    937     {
    938         {    0x2c,  7},
    939         {   0x1dd, 10},
    940         {  0x1efc, 14}
    941     }
    942 };
    943 
    944 static const VLCtable coeff_RVLCtab20[8][2] =
    945 {
    946     /* run = 10 */
    947     {
    948         {    0x2d,  7},
    949         {   0x3bc, 11}
    950     },
    951     /* run = 11 */
    952     {
    953         {    0x34,  7},
    954         {   0x77c, 12}
    955     },
    956     /* run = 12 */
    957     {
    958         {    0x6d,  8},
    959         {   0xf7d, 13}
    960     },
    961     /* run = 13 */
    962     {
    963         {    0x74,  8},
    964         {  0x1efd, 14}
    965     },
    966     /* run = 14 */
    967     {
    968         {    0x75,  8},
    969         {  0x1f7c, 14}
    970     },
    971     /* run = 15 */
    972     {
    973         {    0xdc,  9},
    974         {  0x1f7d, 14}
    975     },
    976     /* run = 16 */
    977     {
    978         {    0xdd,  9},
    979         {  0x1fbc, 14}
    980     },
    981     /* run = 17 */
    982     {
    983         {    0xec,  9},
    984         {  0x37fc, 15}
    985     }
    986 };
    987 
    988 static const VLCtable coeff_RVLCtab21[21] =
    989 {
    990     /* run = 18 -> 38 */
    991     {   0x1ec, 10},
    992     {   0x1ed, 10},
    993     {   0x1f4, 10},
    994     {   0x3bd, 11},
    995     {   0x3dc, 11},
    996     {   0x3dd, 11},
    997     {   0x3ec, 11},
    998     {   0x3ed, 11},
    999     {   0x3f4, 11},
   1000     {   0x77d, 12},
   1001     {   0x7bc, 12},
   1002     {   0x7bd, 12},
   1003     {   0xfbc, 13},
   1004     {   0xfbd, 13},
   1005     {   0xfdc, 13},
   1006     {   0xfdd, 13},
   1007     {  0x1fbd, 14},
   1008     {  0x1fdc, 14},
   1009     {  0x1fdd, 14},
   1010     {  0x37fd, 15},
   1011     {  0x3bfc, 15}
   1012 };
   1013 
   1014 
   1015 /* first coeffs of last = 1. indexing by [run][level-1] */
   1016 
   1017 static const VLCtable coeff_RVLCtab22[2][5] =
   1018 {
   1019     /* run = 0 */
   1020     {
   1021         {     0xb,  4},
   1022         {    0x78,  8},
   1023         {   0x3f5, 11},
   1024         {   0xfec, 13},
   1025         {  0x1fec, 14}
   1026     },
   1027     /* run = 1 */
   1028     {
   1029         {    0x12,  5},
   1030         {    0xed,  9},
   1031         {   0x7dc, 12},
   1032         {  0x1fed, 14},
   1033         {  0x3bfd, 15}
   1034     }
   1035 
   1036 };
   1037 
   1038 static const VLCtable coeff_RVLCtab23[3] =
   1039 {
   1040     /* run = 2 */
   1041     {    0x13,  5},
   1042     {   0x3f8, 11},
   1043     {  0x3dfc, 15}
   1044 
   1045 };
   1046 
   1047 static const VLCtable coeff_RVLCtab24[11][2] =
   1048 {
   1049     /* run = 3 */
   1050     {
   1051         {    0x18,  6},
   1052         {   0x7dd, 12}
   1053     },
   1054     /* run = 4 */
   1055     {
   1056         {    0x19,  6},
   1057         {   0x7ec, 12}
   1058     },
   1059     /* run = 5 */
   1060     {
   1061         {    0x22,  6},
   1062         {   0xfed, 13}
   1063     },
   1064     /* run = 6 */
   1065     {
   1066         {    0x23,  6},
   1067         {   0xff4, 13}
   1068     },
   1069     /* run = 7 */
   1070     {
   1071         {    0x35,  7},
   1072         {   0xff5, 13}
   1073     },
   1074     /* run = 8 */
   1075     {
   1076         {    0x38,  7},
   1077         {   0xff8, 13}
   1078     },
   1079     /* run = 9 */
   1080     {
   1081         {    0x39,  7},
   1082         {   0xff9, 13}
   1083     },
   1084     /* run = 10 */
   1085     {
   1086         {    0x42,  7},
   1087         {  0x1ff4, 14}
   1088     },
   1089     /* run = 11 */
   1090     {
   1091         {    0x43,  7},
   1092         {  0x1ff5, 14}
   1093     },
   1094     /* run = 12 */
   1095     {
   1096         {    0x79,  8},
   1097         {  0x1ff8, 14}
   1098     },
   1099     /* run = 13 */
   1100     {
   1101         {    0x82,  8},
   1102         {  0x3dfd, 15}
   1103     }
   1104 
   1105 };
   1106 
   1107 static const VLCtable coeff_RVLCtab25[32] =
   1108 {
   1109     /* run = 14 -> 44 */
   1110     {    0x83,  8},
   1111     {    0xf4,  9},
   1112     {    0xf5,  9},
   1113     {    0xf8,  9},
   1114     {    0xf9,  9},
   1115     {   0x102,  9},
   1116     {   0x103,  9},
   1117     {   0x1f5, 10},
   1118     {   0x1f8, 10},
   1119     {   0x1f9, 10},
   1120     {   0x202, 10},
   1121     {   0x203, 10},
   1122     {   0x3f9, 11},
   1123     {   0x402, 11},
   1124     {   0x403, 11},
   1125     {   0x7ed, 12},
   1126     {   0x7f4, 12},
   1127     {   0x7f5, 12},
   1128     {   0x7f8, 12},
   1129     {   0x7f9, 12},
   1130     {   0x802, 12},
   1131     {   0x803, 12},
   1132     {  0x1002, 13},
   1133     {  0x1003, 13},
   1134     {  0x1ff9, 14},
   1135     {  0x2002, 14},
   1136     {  0x2003, 14},
   1137     {  0x3efc, 15},
   1138     {  0x3efd, 15},
   1139     {  0x3f7c, 15},
   1140     {  0x3f7d, 15}
   1141 };
   1142 
   1143 #endif /* NO_RVLC */
   1144 
   1145 #endif /* _VLC_ENC_TAB_H_ */
   1146 
   1147