--- vlc_codes.h 2003/02/09 06:33:52 1.6.2.4 +++ vlc_codes.h 2002/10/19 11:41:11 1.11 @@ -1,387 +1,589 @@ +/***************************************************************************** + * + * XVID MPEG-4 VIDEO CODEC + * - Vector Length Coding tables - + * + * Copyright(C) 2002 Michael Militzer + * + * + * This program is an implementation of a part of one or more MPEG-4 + * Video tools as specified in ISO/IEC 14496-2 standard. Those intending + * to use this software module in hardware or software products are + * advised that its use may infringe existing patents or copyrights, and + * any such use would be at such party's own risk. The original + * developer of this software module and his/her company, and subsequent + * editors and their companies, will have no liability for use of this + * software or modifications or derivatives thereof. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id: vlc_codes.h,v 1.11 2002/10/19 11:41:11 edgomez Exp $ + * + ****************************************************************************/ + #ifndef _VLC_CODES_H_ #define _VLC_CODES_H_ #include "../portab.h" +#include "mbcoding.h" #define VLC_ERROR (-1) +#define ESCAPE 7167 -#define ESCAPE 3 -#define ESCAPE1 6 -#define ESCAPE2 14 -#define ESCAPE3 15 +/***************************************************************************** + * The Vector Length Coding structure + ****************************************************************************/ typedef struct { uint32_t code; - uint8_t len; + int8_t len; } VLC; -typedef struct -{ - uint8_t last; - uint8_t run; - int8_t level; -} -EVENT; +static VLC *DCT3D[2]; -typedef struct -{ - uint8_t len; - EVENT event; -} -REVERSE_EVENT; -typedef struct -{ - VLC vlc; - EVENT event; -} -VLC_TABLE; +/***************************************************************************** + * common tables between encoder/decoder + ****************************************************************************/ +/* constants taken from momusys/vm_common/inlcude/max_level.h */ +static char const max_level[4][64] = { + /* intra, last = 0 */ + { + 27, 10, 5, 4, 3, 3, 3, 3, + 2, 2, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 + }, -/****************************************************************** - * common tables between encoder/decoder * - ******************************************************************/ + /* intra, last = 1 */ + { + 8, 3, 2, 2, 2, 2, 2, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 + }, -static VLC_TABLE const coeff_tab[2][102] = -{ - /* intra = 0 */ + /* inter, last = 0 */ { - {{ 2, 2}, {0, 0, 1}}, - {{15, 4}, {0, 0, 2}}, - {{21, 6}, {0, 0, 3}}, - {{23, 7}, {0, 0, 4}}, - {{31, 8}, {0, 0, 5}}, - {{37, 9}, {0, 0, 6}}, - {{36, 9}, {0, 0, 7}}, - {{33, 10}, {0, 0, 8}}, - {{32, 10}, {0, 0, 9}}, - {{ 7, 11}, {0, 0, 10}}, - {{ 6, 11}, {0, 0, 11}}, - {{32, 11}, {0, 0, 12}}, - {{ 6, 3}, {0, 1, 1}}, - {{20, 6}, {0, 1, 2}}, - {{30, 8}, {0, 1, 3}}, - {{15, 10}, {0, 1, 4}}, - {{33, 11}, {0, 1, 5}}, - {{80, 12}, {0, 1, 6}}, - {{14, 4}, {0, 2, 1}}, - {{29, 8}, {0, 2, 2}}, - {{14, 10}, {0, 2, 3}}, - {{81, 12}, {0, 2, 4}}, - {{13, 5}, {0, 3, 1}}, - {{35, 9}, {0, 3, 2}}, - {{13, 10}, {0, 3, 3}}, - {{12, 5}, {0, 4, 1}}, - {{34, 9}, {0, 4, 2}}, - {{82, 12}, {0, 4, 3}}, - {{11, 5}, {0, 5, 1}}, - {{12, 10}, {0, 5, 2}}, - {{83, 12}, {0, 5, 3}}, - {{19, 6}, {0, 6, 1}}, - {{11, 10}, {0, 6, 2}}, - {{84, 12}, {0, 6, 3}}, - {{18, 6}, {0, 7, 1}}, - {{10, 10}, {0, 7, 2}}, - {{17, 6}, {0, 8, 1}}, - {{ 9, 10}, {0, 8, 2}}, - {{16, 6}, {0, 9, 1}}, - {{ 8, 10}, {0, 9, 2}}, - {{22, 7}, {0, 10, 1}}, - {{85, 12}, {0, 10, 2}}, - {{21, 7}, {0, 11, 1}}, - {{20, 7}, {0, 12, 1}}, - {{28, 8}, {0, 13, 1}}, - {{27, 8}, {0, 14, 1}}, - {{33, 9}, {0, 15, 1}}, - {{32, 9}, {0, 16, 1}}, - {{31, 9}, {0, 17, 1}}, - {{30, 9}, {0, 18, 1}}, - {{29, 9}, {0, 19, 1}}, - {{28, 9}, {0, 20, 1}}, - {{27, 9}, {0, 21, 1}}, - {{26, 9}, {0, 22, 1}}, - {{34, 11}, {0, 23, 1}}, - {{35, 11}, {0, 24, 1}}, - {{86, 12}, {0, 25, 1}}, - {{87, 12}, {0, 26, 1}}, - {{ 7, 4}, {1, 0, 1}}, - {{25, 9}, {1, 0, 2}}, - {{ 5, 11}, {1, 0, 3}}, - {{15, 6}, {1, 1, 1}}, - {{ 4, 11}, {1, 1, 2}}, - {{14, 6}, {1, 2, 1}}, - {{13, 6}, {1, 3, 1}}, - {{12, 6}, {1, 4, 1}}, - {{19, 7}, {1, 5, 1}}, - {{18, 7}, {1, 6, 1}}, - {{17, 7}, {1, 7, 1}}, - {{16, 7}, {1, 8, 1}}, - {{26, 8}, {1, 9, 1}}, - {{25, 8}, {1, 10, 1}}, - {{24, 8}, {1, 11, 1}}, - {{23, 8}, {1, 12, 1}}, - {{22, 8}, {1, 13, 1}}, - {{21, 8}, {1, 14, 1}}, - {{20, 8}, {1, 15, 1}}, - {{19, 8}, {1, 16, 1}}, - {{24, 9}, {1, 17, 1}}, - {{23, 9}, {1, 18, 1}}, - {{22, 9}, {1, 19, 1}}, - {{21, 9}, {1, 20, 1}}, - {{20, 9}, {1, 21, 1}}, - {{19, 9}, {1, 22, 1}}, - {{18, 9}, {1, 23, 1}}, - {{17, 9}, {1, 24, 1}}, - {{ 7, 10}, {1, 25, 1}}, - {{ 6, 10}, {1, 26, 1}}, - {{ 5, 10}, {1, 27, 1}}, - {{ 4, 10}, {1, 28, 1}}, - {{36, 11}, {1, 29, 1}}, - {{37, 11}, {1, 30, 1}}, - {{38, 11}, {1, 31, 1}}, - {{39, 11}, {1, 32, 1}}, - {{88, 12}, {1, 33, 1}}, - {{89, 12}, {1, 34, 1}}, - {{90, 12}, {1, 35, 1}}, - {{91, 12}, {1, 36, 1}}, - {{92, 12}, {1, 37, 1}}, - {{93, 12}, {1, 38, 1}}, - {{94, 12}, {1, 39, 1}}, - {{95, 12}, {1, 40, 1}} - }, - /* intra = 1 */ + 12, 6, 4, 3, 3, 3, 3, 2, + 2, 2, 2, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 + }, + + /* inter, last = 1 */ { - {{ 2, 2}, {0, 0, 1}}, - {{15, 4}, {0, 0, 3}}, - {{21, 6}, {0, 0, 6}}, - {{23, 7}, {0, 0, 9}}, - {{31, 8}, {0, 0, 10}}, - {{37, 9}, {0, 0, 13}}, - {{36, 9}, {0, 0, 14}}, - {{33, 10}, {0, 0, 17}}, - {{32, 10}, {0, 0, 18}}, - {{ 7, 11}, {0, 0, 21}}, - {{ 6, 11}, {0, 0, 22}}, - {{32, 11}, {0, 0, 23}}, - {{ 6, 3}, {0, 0, 2}}, - {{20, 6}, {0, 1, 2}}, - {{30, 8}, {0, 0, 11}}, - {{15, 10}, {0, 0, 19}}, - {{33, 11}, {0, 0, 24}}, - {{80, 12}, {0, 0, 25}}, - {{14, 4}, {0, 1, 1}}, - {{29, 8}, {0, 0, 12}}, - {{14, 10}, {0, 0, 20}}, - {{81, 12}, {0, 0, 26}}, - {{13, 5}, {0, 0, 4}}, - {{35, 9}, {0, 0, 15}}, - {{13, 10}, {0, 1, 7}}, - {{12, 5}, {0, 0, 5}}, - {{34, 9}, {0, 4, 2}}, - {{82, 12}, {0, 0, 27}}, - {{11, 5}, {0, 2, 1}}, - {{12, 10}, {0, 2, 4}}, - {{83, 12}, {0, 1, 9}}, - {{19, 6}, {0, 0, 7}}, - {{11, 10}, {0, 3, 4}}, - {{84, 12}, {0, 6, 3}}, - {{18, 6}, {0, 0, 8}}, - {{10, 10}, {0, 4, 3}}, - {{17, 6}, {0, 3, 1}}, - {{ 9, 10}, {0, 8, 2}}, - {{16, 6}, {0, 4, 1}}, - {{ 8, 10}, {0, 5, 3}}, - {{22, 7}, {0, 1, 3}}, - {{85, 12}, {0, 1, 10}}, - {{21, 7}, {0, 2, 2}}, - {{20, 7}, {0, 7, 1}}, - {{28, 8}, {0, 1, 4}}, - {{27, 8}, {0, 3, 2}}, - {{33, 9}, {0, 0, 16}}, - {{32, 9}, {0, 1, 5}}, - {{31, 9}, {0, 1, 6}}, - {{30, 9}, {0, 2, 3}}, - {{29, 9}, {0, 3, 3}}, - {{28, 9}, {0, 5, 2}}, - {{27, 9}, {0, 6, 2}}, - {{26, 9}, {0, 7, 2}}, - {{34, 11}, {0, 1, 8}}, - {{35, 11}, {0, 9, 2}}, - {{86, 12}, {0, 2, 5}}, - {{87, 12}, {0, 7, 3}}, - {{ 7, 4}, {1, 0, 1}}, - {{25, 9}, {0, 11, 1}}, - {{ 5, 11}, {1, 0, 6}}, - {{15, 6}, {1, 1, 1}}, - {{ 4, 11}, {1, 0, 7}}, - {{14, 6}, {1, 2, 1}}, - {{13, 6}, {0, 5, 1}}, - {{12, 6}, {1, 0, 2}}, - {{19, 7}, {1, 5, 1}}, - {{18, 7}, {0, 6, 1}}, - {{17, 7}, {1, 3, 1}}, - {{16, 7}, {1, 4, 1}}, - {{26, 8}, {1, 9, 1}}, - {{25, 8}, {0, 8, 1}}, - {{24, 8}, {0, 9, 1}}, - {{23, 8}, {0, 10, 1}}, - {{22, 8}, {1, 0, 3}}, - {{21, 8}, {1, 6, 1}}, - {{20, 8}, {1, 7, 1}}, - {{19, 8}, {1, 8, 1}}, - {{24, 9}, {0, 12, 1}}, - {{23, 9}, {1, 0, 4}}, - {{22, 9}, {1, 1, 2}}, - {{21, 9}, {1, 10, 1}}, - {{20, 9}, {1, 11, 1}}, - {{19, 9}, {1, 12, 1}}, - {{18, 9}, {1, 13, 1}}, - {{17, 9}, {1, 14, 1}}, - {{ 7, 10}, {0, 13, 1}}, - {{ 6, 10}, {1, 0, 5}}, - {{ 5, 10}, {1, 1, 3}}, - {{ 4, 10}, {1, 2, 2}}, - {{36, 11}, {1, 3, 2}}, - {{37, 11}, {1, 4, 2}}, - {{38, 11}, {1, 15, 1}}, - {{39, 11}, {1, 16, 1}}, - {{88, 12}, {0, 14, 1}}, - {{89, 12}, {1, 0, 8}}, - {{90, 12}, {1, 5, 2}}, - {{91, 12}, {1, 6, 2}}, - {{92, 12}, {1, 17, 1}}, - {{93, 12}, {1, 18, 1}}, - {{94, 12}, {1, 19, 1}}, - {{95, 12}, {1, 20, 1}} - } + 3, 2, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 + } }; -/* constants taken from momusys/vm_common/inlcude/max_level.h */ -static uint8_t const max_level[2][2][64] = { +static char const max_run[4][256] = { + /* intra, last = 0 */ { - /* intra = 0, last = 0 */ - { - 12, 6, 4, 3, 3, 3, 3, 2, - 2, 2, 2, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 - }, - /* intra = 0, last = 1 */ - { - 3, 2, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 - } - }, + 0, 14, 9, 7, 3, 2, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0,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0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 + } }; -static uint8_t const max_run[2][2][64] = { + +/****************************************************************** + * encoder tables * + ******************************************************************/ + +/* DCT coefficients. Four tables, two for last = 0, two for last = 1. + the sign bit must be added afterwards. */ + +/* first part of coeffs for last = 0. Indexed by [run][level-1] */ + +static VLC const coeff_tab0[2][12] = { + /* run = 0 */ { - /* intra = 0, last = 0 */ - { - 0, 26, 10, 6, 2, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - }, - /* intra = 0, last = 1 */ - { - 0, 40, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - } + {0x02, 2}, {0x0f, 4}, {0x15, 6}, {0x17, 7}, + {0x1f, 8}, {0x25, 9}, {0x24, 9}, {0x21, 10}, + {0x20, 10}, {0x07, 11}, {0x06, 11}, {0x20, 11} }, + + /* run = 1 */ { - /* intra = 1, last = 0 */ - { - 0, 14, 9, 7, 3, 2, 1, 1, - 1, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - }, - /* intra = 1, last = 1 */ - { - 0, 20, 6, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - } + {0x06, 3}, {0x14, 6}, {0x1e, 8}, {0x0f, 10}, + {0x21, 11}, {0x50, 12}, {0x00, 0}, {0x00, 0}, + {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0} } }; -/****************************************************************** - * encoder tables * - ******************************************************************/ +/* rest of coeffs for last = 0. indexing by [run-2][level-1] */ -static VLC sprite_trajectory_code[32768]; +static VLC const coeff_tab1[25][4] = { + /* First row is run=2, then each row is run 2 + index */ + {{0x0e, 4}, {0x1d, 8}, {0x0e, 10}, {0x51, 12}}, + {{0x0d, 5}, {0x23, 9}, {0x0d, 10}, {0x00, 0}}, + {{0x0c, 5}, {0x22, 9}, {0x52, 12}, {0x00, 0}}, + {{0x0b, 5}, {0x0c, 10}, {0x53, 12}, {0x00, 0}}, + {{0x13, 6}, {0x0b, 10}, {0x54, 12}, {0x00, 0}}, + {{0x12, 6}, {0x0a, 10}, {0x00, 0}, {0x00, 0}}, + {{0x11, 6}, {0x09, 10}, {0x00, 0}, {0x00, 0}}, + {{0x10, 6}, {0x08, 10}, {0x00, 0}, {0x00, 0}}, + {{0x16, 7}, {0x55, 12}, {0x00, 0}, {0x00, 0}}, + {{0x15, 7}, {0x00, 0}, {0x00, 0}, {0x00, 0}}, + {{0x14, 7}, {0x00, 0}, {0x00, 0}, {0x00, 0}}, + {{0x1c, 8}, {0x00, 0}, {0x00, 0}, {0x00, 0}}, + {{0x1b, 8}, {0x00, 0}, {0x00, 0}, {0x00, 0}}, + {{0x21, 9}, {0x00, 0}, {0x00, 0}, {0x00, 0}}, + {{0x20, 9}, {0x00, 0}, {0x00, 0}, {0x00, 0}}, + {{0x1f, 9}, {0x00, 0}, {0x00, 0}, {0x00, 0}}, + {{0x1e, 9}, {0x00, 0}, {0x00, 0}, {0x00, 0}}, + {{0x1d, 9}, {0x00, 0}, {0x00, 0}, {0x00, 0}}, + {{0x1c, 9}, {0x00, 0}, {0x00, 0}, {0x00, 0}}, + {{0x1b, 9}, {0x00, 0}, {0x00, 0}, {0x00, 0}}, + {{0x1a, 9}, {0x00, 0}, {0x00, 0}, {0x00, 0}}, + {{0x22, 11}, {0x00, 0}, {0x00, 0}, {0x00, 0}}, + {{0x23, 11}, {0x00, 0}, {0x00, 0}, {0x00, 0}}, + {{0x56, 12}, {0x00, 0}, {0x00, 0}, {0x00, 0}}, + {{0x57, 12}, {0x00, 0}, {0x00, 0}, {0x00, 0}} -static VLC sprite_trajectory_len[15] = { - { 0x00 , 2}, - { 0x02 , 3}, { 0x03, 3}, { 0x04, 3}, { 0x05, 3}, { 0x06, 3}, - { 0x0E , 4}, { 0x1E, 5}, { 0x3E, 6}, { 0x7F, 7}, { 0xFE, 8}, - { 0x1FE, 9}, {0x3FE,10}, {0x7FE,11}, {0xFFE,12} }; +}; +/* first coeffs of last = 1. indexing by [run][level-1] */ -/* DCT coefficients. Four tables, two for last = 0, two for last = 1. - the sign bit must be added afterwards. */ +static VLC const coeff_tab2[2][3] = { + /* run = 0 */ + {{0x07, 4}, {0x19, 9}, {0x05, 11}}, + /* run = 1 */ + {{0x0f, 6}, {0x04, 11}, {0x00, 0}} +}; + +/* rest of coeffs for last = 1. indexing by [run-2] */ + +static VLC const coeff_tab3[40][1] = { + {{0x0e, 6}}, {{0x0d, 6}}, {{0x0c, 6}}, {{0x13, 7}}, + {{0x12, 7}}, {{0x11, 7}}, {{0x10, 7}}, {{0x1a, 8}}, + {{0x19, 8}}, {{0x18, 8}}, {{0x17, 8}}, {{0x16, 8}}, + {{0x15, 8}}, {{0x14, 8}}, {{0x13, 8}}, {{0x18, 9}}, + {{0x17, 9}}, {{0x16, 9}}, {{0x15, 9}}, {{0x14, 9}}, + {{0x13, 9}}, {{0x12, 9}}, {{0x11, 9}}, {{0x07, 10}}, + {{0x06, 10}}, {{0x05, 10}}, {{0x04, 10}}, {{0x24, 11}}, + {{0x25, 11}}, {{0x26, 11}}, {{0x27, 11}}, {{0x58, 12}}, + {{0x59, 12}}, {{0x5a, 12}}, {{0x5b, 12}}, {{0x5c, 12}}, + {{0x5d, 12}}, {{0x5e, 12}}, {{0x5f, 12}}, {{0x00, 0}} +}; + +/* + * New tables for Intra luminance coefficients. Same codewords, + * different meaning + */ + +/* Coeffs for last = 0, run = 0. Indexed by [level-1] */ + +static VLC const coeff_tab4[27] = { + /* run = 0 */ + {0x02, 2}, {0x06, 3}, {0x0f, 4}, + {0x0d, 5}, {0x0c, 5}, {0x15, 6}, + {0x13, 6}, {0x12, 6}, {0x17, 7}, + {0x1f, 8}, {0x1e, 8}, {0x1d, 8}, + {0x25, 9}, {0x24, 9}, {0x23, 9}, + {0x21, 9}, {0x21, 10}, {0x20, 10}, + {0x0f, 10}, {0x0e, 10}, {0x07, 11}, + {0x06, 11}, {0x20, 11}, {0x21, 11}, + {0x50, 12}, {0x51, 12}, {0x52, 12} +}; + +/* Coeffs for last = 0, run = 1. Indexed by [level-1] */ + +static VLC const coeff_tab5[10] = { + {0x0e, 4}, {0x14, 6}, {0x16, 7}, {0x1c, 8}, {0x20, 9}, + {0x1f, 9}, {0x0d, 10}, {0x22, 11}, {0x53, 12}, {0x55, 12} +}; + +/* Coeffs for last = 0, run = 2 -> 9. Indexed by [run-2][level-1] */ + +static VLC coeff_tab6[8][5] = { + /* run = 2 */ + {{0x0b, 5}, {0x15, 7}, {0x1e, 9}, {0x0c, 10}, {0x56, 12}}, + + /* run = 3 */ + {{0x11, 6}, {0x1b, 8}, {0x1d, 9}, {0x0b, 10}, {0x00, 0}}, + + /* run = 4 */ + {{0x10, 6}, {0x22, 9}, {0x0a, 10}, {0x00, 0}, {0x00, 0}}, + + /* run = 5 */ + {{0x0d, 6}, {0x1c, 9}, {0x08, 10}, {0x00, 0}, {0x00, 0}}, -/* MCBPC Indexing by cbpc in first two bits, mode in last two. - CBPC as in table 4/H.263, MB type (mode): 3 = 01, 4 = 10. - Example: cbpc = 01 and mode = 4 gives index = 0110 = 6. */ + /* run = 6 */ + {{0x12, 7}, {0x1b, 9}, {0x54, 12}, {0x00, 0}, {0x00, 0}}, -static VLC mcbpc_intra_tab[15] = { + /* run = 7 */ + {{0x14, 7}, {0x1a, 9}, {0x57, 12}, {0x00, 0}, {0x00, 0}}, + + /* run = 8 */ + {{0x19, 8}, {0x09, 10}, {0x00, 0}, {0x00, 0}, {0x00, 0}}, + + /* run = 9 */ + {{0x18, 8}, {0x23, 11}, {0x00, 0}, {0x00, 0}, {0x00, 0}} +}; + +/* Coeffs for last = 0, run = 10 -> 14. Indexed by [run-10] */ + +static VLC const coeff_tab7[5][1] = { + {{0x17, 8}}, + {{0x19, 9}}, + {{0x18, 9}}, + {{0x07, 10}}, + {{0x58, 12}} +}; + +/* Coeffs for last = 1, run = 0. Indexed by [level-1] */ + +static VLC const coeff_tab8[8] = { + {0x07, 4}, {0x0c, 6}, {0x16, 8}, {0x17, 9}, + {0x06, 10}, {0x05, 11}, {0x04, 11}, {0x59, 12} +}; + +/* Coeffs for last = 1, run = 1 -> 6. Indexed by [run-1][level-1] */ + +static VLC const coeff_tab9[6][3] = { + /* run = 1 */ + {{0x0f, 6}, {0x16, 9}, {0x05, 10}}, + + /* run = 2 */ + {{0x0e, 6}, {0x04, 10}, {0x00, 0}}, + + /* run = 3 */ + {{0x11, 7}, {0x24, 11}, {0x00, 0}}, + + /* run = 4 */ + {{0x10, 7}, {0x25, 11}, {0x00, 0}}, + + /* run = 5 */ + {{0x13, 7}, {0x5a, 12}, {0x00, 0}}, + + /* run = 6 */ + {{0x15, 8}, {0x5b, 12}, {0x00, 0}} +}; + +/* Coeffs for last = 1, run = 7 -> 20. Indexed by [run-7] */ + +static VLC const coeff_tab10[14][1] = { + {{0x14, 8}}, + {{0x13, 8}}, + {{0x1a, 8}}, + {{0x15, 9}}, + {{0x14, 9}}, + {{0x13, 9}}, + {{0x12, 9}}, + {{0x11, 9}}, + {{0x26, 11}}, + {{0x27, 11}}, + {{0x5c, 12}}, + {{0x5d, 12}}, + {{0x5e, 12}}, + {{0x5f, 12}} +}; + + +static VLC const *coeff_intra_last0[15] = { + coeff_tab4, + coeff_tab5, + coeff_tab6[0], + coeff_tab6[1], + coeff_tab6[2], + coeff_tab6[3], + coeff_tab6[4], + coeff_tab6[5], + coeff_tab6[6], + coeff_tab6[7], + coeff_tab7[0], + coeff_tab7[1], + coeff_tab7[2], + coeff_tab7[3], + coeff_tab7[4] +}; + +static VLC const *coeff_intra_last1[21] = { + coeff_tab8, + coeff_tab9[0], + coeff_tab9[1], + coeff_tab9[2], + coeff_tab9[3], + coeff_tab9[4], + coeff_tab9[5], + coeff_tab10[0], + coeff_tab10[1], + coeff_tab10[2], + coeff_tab10[3], + coeff_tab10[4], + coeff_tab10[5], + coeff_tab10[6], + coeff_tab10[7], + coeff_tab10[8], + coeff_tab10[9], + coeff_tab10[10], + coeff_tab10[11], + coeff_tab10[12], + coeff_tab10[13], +}; + +static VLC const *coeff_inter_last0[27] = { + coeff_tab0[0], + coeff_tab0[1], + coeff_tab1[0], + coeff_tab1[1], + coeff_tab1[2], + coeff_tab1[3], + coeff_tab1[4], + coeff_tab1[5], + coeff_tab1[6], + coeff_tab1[7], + coeff_tab1[8], + coeff_tab1[9], + coeff_tab1[10], + coeff_tab1[11], + coeff_tab1[12], + coeff_tab1[13], + coeff_tab1[14], + coeff_tab1[15], + coeff_tab1[16], + coeff_tab1[17], + coeff_tab1[18], + coeff_tab1[19], + coeff_tab1[20], + coeff_tab1[21], + coeff_tab1[22], + coeff_tab1[23], + coeff_tab1[24], +}; + +static VLC const *coeff_inter_last1[42] = { + coeff_tab2[0], + coeff_tab2[1], + coeff_tab3[0], + coeff_tab3[1], + coeff_tab3[2], + coeff_tab3[3], + coeff_tab3[4], + coeff_tab3[5], + coeff_tab3[6], + coeff_tab3[7], + coeff_tab3[8], + coeff_tab3[9], + coeff_tab3[10], + coeff_tab3[11], + coeff_tab3[12], + coeff_tab3[13], + coeff_tab3[14], + coeff_tab3[15], + coeff_tab3[16], + coeff_tab3[17], + coeff_tab3[18], + coeff_tab3[19], + coeff_tab3[20], + coeff_tab3[21], + coeff_tab3[22], + coeff_tab3[23], + coeff_tab3[24], + coeff_tab3[25], + coeff_tab3[26], + coeff_tab3[27], + coeff_tab3[28], + coeff_tab3[29], + coeff_tab3[30], + coeff_tab3[31], + coeff_tab3[32], + coeff_tab3[33], + coeff_tab3[34], + coeff_tab3[35], + coeff_tab3[36], + coeff_tab3[37], + coeff_tab3[38], + coeff_tab3[39], +}; + +static VLC const **coeff_vlc[4] = { + coeff_intra_last0, + coeff_intra_last1, + coeff_inter_last0, + coeff_inter_last1, +}; + +/* + * MCBPC Indexing by cbpc in first two bits, mode in last two. + * CBPC as in table 4/H.263, MB type (mode): 3 = 01, 4 = 10. + * Example: cbpc = 01 and mode = 4 gives index = 0110 = 6. + */ + +static VLC const mcbpc_intra_tab[15] = { {0x01, 9}, {0x01, 1}, {0x01, 4}, {0x00, 0}, {0x00, 0}, {0x01, 3}, {0x01, 6}, {0x00, 0}, {0x00, 0}, {0x02, 3}, {0x02, 6}, {0x00, 0}, @@ -391,19 +593,19 @@ /* MCBPC inter. Addressing: 5 bit ccmmm (cc = CBPC, mmm = mode (1-4 binary)) */ -static VLC mcbpc_inter_tab[29] = { +static VLC const mcbpc_inter_tab[29] = { {1, 1}, {3, 3}, {2, 3}, {3, 5}, {4, 6}, {1, 9}, {0, 0}, {0, 0}, {3, 4}, {7, 7}, {5, 7}, {4, 8}, {4, 9}, {0, 0}, {0, 0}, {0, 0}, {2, 4}, {6, 7}, {4, 7}, {3, 8}, {3, 9}, {0, 0}, {0, 0}, {0, 0}, {5, 6}, {5, 9}, {5, 8}, {3, 7}, {2, 9} }; -static const VLC cbpy_tab[16] = { +static VLC const cbpy_tab[16] = { {3, 4}, {5, 5}, {4, 5}, {9, 4}, {3, 5}, {7, 4}, {2, 6}, {11, 4}, {2, 5}, {3, 6}, {5, 4}, {10, 4}, {4, 4}, {8, 4}, {6, 4}, {3, 2} }; -static const VLC dcy_tab[511] = { +static VLC const dcy_tab[511] = { {0x100, 15}, {0x101, 15}, {0x102, 15}, {0x103, 15}, {0x104, 15}, {0x105, 15}, {0x106, 15}, {0x107, 15}, {0x108, 15}, {0x109, 15}, {0x10a, 15}, {0x10b, 15}, @@ -534,7 +736,7 @@ {0x1fd, 15}, {0x1fe, 15}, {0x1ff, 15}, }; -static const VLC dcc_tab[511] = { +static VLC const dcc_tab[511] = { {0x100, 16}, {0x101, 16}, {0x102, 16}, {0x103, 16}, {0x104, 16}, {0x105, 16}, {0x106, 16}, {0x107, 16}, {0x108, 16}, {0x109, 16}, {0x10a, 16}, {0x10b, 16}, @@ -666,7 +868,7 @@ }; -static const VLC mb_motion_table[65] = { +static VLC const mb_motion_table[65] = { {0x05, 13}, {0x07, 13}, {0x05, 12}, {0x07, 12}, {0x09, 12}, {0x0b, 12}, {0x0d, 12}, {0x0f, 12}, {0x09, 11}, {0x0b, 11}, {0x0d, 11}, {0x0f, 11}, @@ -702,6 +904,7 @@ {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1} }; + static VLC const mcbpc_inter_table[257] = { {VLC_ERROR, 0}, {255, 9}, {52, 9}, {36, 9}, {20, 9}, {49, 9}, {35, 8}, {35, 8}, {19, 8}, {19, 8}, {50, 8}, {50, 8}, {51, 7}, {51, 7}, {51, 7}, {51, 7}, @@ -749,6 +952,7 @@ {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2} }; + static VLC const TMNMVtab0[] = { {3, 4}, {-3, 4}, {2, 3}, {2, 3}, {-2, 3}, {-2, 3}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {-1, 2}, {-1, 2}, {-1, 2}, {-1, 2} @@ -815,15 +1019,186 @@ {-13, 10}, {-13, 10}, {-13, 10}, {-13, 10} }; + +static VLC const DCT3Dtab0[] = { + {4225, 7}, {4209, 7}, {4193, 7}, {4177, 7}, {193, 7}, {177, 7}, + {161, 7}, {4, 7}, {4161, 6}, {4161, 6}, {4145, 6}, {4145, 6}, + {4129, 6}, {4129, 6}, {4113, 6}, {4113, 6}, {145, 6}, {145, 6}, + {129, 6}, {129, 6}, {113, 6}, {113, 6}, {97, 6}, {97, 6}, + {18, 6}, {18, 6}, {3, 6}, {3, 6}, {81, 5}, {81, 5}, + {81, 5}, {81, 5}, {65, 5}, {65, 5}, {65, 5}, {65, 5}, + {49, 5}, {49, 5}, {49, 5}, {49, 5}, {4097, 4}, {4097, 4}, + {4097, 4}, {4097, 4}, {4097, 4}, {4097, 4}, {4097, 4}, {4097, 4}, + {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}, {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}, {1, 2}, {1, 2}, + {1, 2}, {1, 2}, {17, 3}, {17, 3}, {17, 3}, {17, 3}, + {17, 3}, {17, 3}, {17, 3}, {17, 3}, {17, 3}, {17, 3}, + {17, 3}, {17, 3}, {17, 3}, {17, 3}, {17, 3}, {17, 3}, + {33, 4}, {33, 4}, {33, 4}, {33, 4}, {33, 4}, {33, 4}, + {33, 4}, {33, 4}, {2, 4}, {2, 4}, {2, 4}, {2, 4}, + {2, 4}, {2, 4}, {2, 4}, {2, 4} +}; + + +static VLC const DCT3Dtab1[] = { + {9, 10}, {8, 10}, {4481, 9}, {4481, 9}, {4465, 9}, {4465, 9}, + {4449, 9}, {4449, 9}, {4433, 9}, {4433, 9}, {4417, 9}, {4417, 9}, + {4401, 9}, {4401, 9}, {4385, 9}, {4385, 9}, {4369, 9}, {4369, 9}, + {4098, 9}, {4098, 9}, {353, 9}, {353, 9}, {337, 9}, {337, 9}, + {321, 9}, {321, 9}, {305, 9}, {305, 9}, {289, 9}, {289, 9}, + {273, 9}, {273, 9}, {257, 9}, {257, 9}, {241, 9}, {241, 9}, + {66, 9}, {66, 9}, {50, 9}, {50, 9}, {7, 9}, {7, 9}, + {6, 9}, {6, 9}, {4353, 8}, {4353, 8}, {4353, 8}, {4353, 8}, + {4337, 8}, {4337, 8}, {4337, 8}, {4337, 8}, {4321, 8}, {4321, 8}, + {4321, 8}, {4321, 8}, {4305, 8}, {4305, 8}, {4305, 8}, {4305, 8}, + {4289, 8}, {4289, 8}, {4289, 8}, {4289, 8}, {4273, 8}, {4273, 8}, + {4273, 8}, {4273, 8}, {4257, 8}, {4257, 8}, {4257, 8}, {4257, 8}, + {4241, 8}, {4241, 8}, {4241, 8}, {4241, 8}, {225, 8}, {225, 8}, + {225, 8}, {225, 8}, {209, 8}, {209, 8}, {209, 8}, {209, 8}, + {34, 8}, {34, 8}, {34, 8}, {34, 8}, {19, 8}, {19, 8}, + {19, 8}, {19, 8}, {5, 8}, {5, 8}, {5, 8}, {5, 8} +}; + +static VLC const DCT3Dtab2[] = { + {4114, 11}, {4114, 11}, {4099, 11}, {4099, 11}, {11, 11}, {11, 11}, + {10, 11}, {10, 11}, {4545, 10}, {4545, 10}, {4545, 10}, {4545, 10}, + {4529, 10}, {4529, 10}, {4529, 10}, {4529, 10}, {4513, 10}, {4513, 10}, + {4513, 10}, {4513, 10}, {4497, 10}, {4497, 10}, {4497, 10}, {4497, 10}, + {146, 10}, {146, 10}, {146, 10}, {146, 10}, {130, 10}, {130, 10}, + {130, 10}, {130, 10}, {114, 10}, {114, 10}, {114, 10}, {114, 10}, + {98, 10}, {98, 10}, {98, 10}, {98, 10}, {82, 10}, {82, 10}, + {82, 10}, {82, 10}, {51, 10}, {51, 10}, {51, 10}, {51, 10}, + {35, 10}, {35, 10}, {35, 10}, {35, 10}, {20, 10}, {20, 10}, + {20, 10}, {20, 10}, {12, 11}, {12, 11}, {21, 11}, {21, 11}, + {369, 11}, {369, 11}, {385, 11}, {385, 11}, {4561, 11}, {4561, 11}, + {4577, 11}, {4577, 11}, {4593, 11}, {4593, 11}, {4609, 11}, {4609, 11}, + {22, 12}, {36, 12}, {67, 12}, {83, 12}, {99, 12}, {162, 12}, + {401, 12}, {417, 12}, {4625, 12}, {4641, 12}, {4657, 12}, {4673, 12}, + {4689, 12}, {4705, 12}, {4721, 12}, {4737, 12}, {7167, 7}, + {7167, 7}, {7167, 7}, {7167, 7}, {7167, 7}, {7167, 7}, {7167, 7}, + {7167, 7}, {7167, 7}, {7167, 7}, {7167, 7}, {7167, 7}, {7167, 7}, + {7167, 7}, {7167, 7}, {7167, 7}, {7167, 7}, {7167, 7}, {7167, 7}, + {7167, 7}, {7167, 7}, {7167, 7}, {7167, 7}, {7167, 7}, {7167, 7}, + {7167, 7}, {7167, 7}, {7167, 7}, {7167, 7}, {7167, 7}, {7167, 7}, + {7167, 7} +}; + + +/* New tables for Intra luminance blocks */ + +static VLC const DCT3Dtab3[] = { + {0x10401, 7}, {0x10301, 7}, {0x00601, 7}, {0x10501, 7}, + {0x00701, 7}, {0x00202, 7}, {0x00103, 7}, {0x00009, 7}, + {0x10002, 6}, {0x10002, 6}, {0x00501, 6}, {0x00501, 6}, + {0x10201, 6}, {0x10201, 6}, {0x10101, 6}, {0x10101, 6}, + {0x00401, 6}, {0x00401, 6}, {0x00301, 6}, {0x00301, 6}, + {0x00008, 6}, {0x00008, 6}, {0x00007, 6}, {0x00007, 6}, + {0x00102, 6}, {0x00102, 6}, {0x00006, 6}, {0x00006, 6}, + {0x00201, 5}, {0x00201, 5}, {0x00201, 5}, {0x00201, 5}, + {0x00005, 5}, {0x00005, 5}, {0x00005, 5}, {0x00005, 5}, + {0x00004, 5}, {0x00004, 5}, {0x00004, 5}, {0x00004, 5}, + {0x10001, 4}, {0x10001, 4}, {0x10001, 4}, {0x10001, 4}, + {0x10001, 4}, {0x10001, 4}, {0x10001, 4}, {0x10001, 4}, + {0x00001, 2}, {0x00001, 2}, {0x00001, 2}, {0x00001, 2}, + {0x00001, 2}, {0x00001, 2}, {0x00001, 2}, {0x00001, 2}, + {0x00001, 2}, {0x00001, 2}, {0x00001, 2}, {0x00001, 2}, + {0x00001, 2}, {0x00001, 2}, {0x00001, 2}, {0x00001, 2}, + {0x00001, 2}, {0x00001, 2}, {0x00001, 2}, {0x00001, 2}, + {0x00001, 2}, {0x00001, 2}, {0x00001, 2}, {0x00001, 2}, + {0x00001, 2}, {0x00001, 2}, {0x00001, 2}, {0x00001, 2}, + {0x00001, 2}, {0x00001, 2}, {0x00001, 2}, {0x00001, 2}, + {0x00002, 3}, {0x00002, 3}, {0x00002, 3}, {0x00002, 3}, + {0x00002, 3}, {0x00002, 3}, {0x00002, 3}, {0x00002, 3}, + {0x00002, 3}, {0x00002, 3}, {0x00002, 3}, {0x00002, 3}, + {0x00002, 3}, {0x00002, 3}, {0x00002, 3}, {0x00002, 3}, + {0x00101, 4}, {0x00101, 4}, {0x00101, 4}, {0x00101, 4}, + {0x00101, 4}, {0x00101, 4}, {0x00101, 4}, {0x00101, 4}, + {0x00003, 4}, {0x00003, 4}, {0x00003, 4}, {0x00003, 4}, + {0x00003, 4}, {0x00003, 4}, {0x00003, 4}, {0x00003, 4} +}; + + +static VLC const DCT3Dtab4[] = { + {0x00012, 10}, {0x00011, 10}, {0x10e01, 9}, {0x10e01, 9}, + {0x10d01, 9}, {0x10d01, 9}, {0x10c01, 9}, {0x10c01, 9}, + {0x10b01, 9}, {0x10b01, 9}, {0x10a01, 9}, {0x10a01, 9}, + {0x10102, 9}, {0x10102, 9}, {0x10004, 9}, {0x10004, 9}, + {0x00c01, 9}, {0x00c01, 9}, {0x00b01, 9}, {0x00b01, 9}, + {0x00702, 9}, {0x00702, 9}, {0x00602, 9}, {0x00602, 9}, + {0x00502, 9}, {0x00502, 9}, {0x00303, 9}, {0x00303, 9}, + {0x00203, 9}, {0x00203, 9}, {0x00106, 9}, {0x00106, 9}, + {0x00105, 9}, {0x00105, 9}, {0x00010, 9}, {0x00010, 9}, + {0x00402, 9}, {0x00402, 9}, {0x0000f, 9}, {0x0000f, 9}, + {0x0000e, 9}, {0x0000e, 9}, {0x0000d, 9}, {0x0000d, 9}, + {0x10801, 8}, {0x10801, 8}, {0x10801, 8}, {0x10801, 8}, + {0x10701, 8}, {0x10701, 8}, {0x10701, 8}, {0x10701, 8}, + {0x10601, 8}, {0x10601, 8}, {0x10601, 8}, {0x10601, 8}, + {0x10003, 8}, {0x10003, 8}, {0x10003, 8}, {0x10003, 8}, + {0x00a01, 8}, {0x00a01, 8}, {0x00a01, 8}, {0x00a01, 8}, + {0x00901, 8}, {0x00901, 8}, {0x00901, 8}, {0x00901, 8}, + {0x00801, 8}, {0x00801, 8}, {0x00801, 8}, {0x00801, 8}, + {0x10901, 8}, {0x10901, 8}, {0x10901, 8}, {0x10901, 8}, + {0x00302, 8}, {0x00302, 8}, {0x00302, 8}, {0x00302, 8}, + {0x00104, 8}, {0x00104, 8}, {0x00104, 8}, {0x00104, 8}, + {0x0000c, 8}, {0x0000c, 8}, {0x0000c, 8}, {0x0000c, 8}, + {0x0000b, 8}, {0x0000b, 8}, {0x0000b, 8}, {0x0000b, 8}, + {0x0000a, 8}, {0x0000a, 8}, {0x0000a, 8}, {0x0000a, 8} +}; + +static VLC const DCT3Dtab5[] = { + {0x10007, 11}, {0x10007, 11}, {0x10006, 11}, {0x10006, 11}, + {0x00016, 11}, {0x00016, 11}, {0x00015, 11}, {0x00015, 11}, + {0x10202, 10}, {0x10202, 10}, {0x10202, 10}, {0x10202, 10}, + {0x10103, 10}, {0x10103, 10}, {0x10103, 10}, {0x10103, 10}, + {0x10005, 10}, {0x10005, 10}, {0x10005, 10}, {0x10005, 10}, + {0x00d01, 10}, {0x00d01, 10}, {0x00d01, 10}, {0x00d01, 10}, + {0x00503, 10}, {0x00503, 10}, {0x00503, 10}, {0x00503, 10}, + {0x00802, 10}, {0x00802, 10}, {0x00802, 10}, {0x00802, 10}, + {0x00403, 10}, {0x00403, 10}, {0x00403, 10}, {0x00403, 10}, + {0x00304, 10}, {0x00304, 10}, {0x00304, 10}, {0x00304, 10}, + {0x00204, 10}, {0x00204, 10}, {0x00204, 10}, {0x00204, 10}, + {0x00107, 10}, {0x00107, 10}, {0x00107, 10}, {0x00107, 10}, + {0x00014, 10}, {0x00014, 10}, {0x00014, 10}, {0x00014, 10}, + {0x00013, 10}, {0x00013, 10}, {0x00013, 10}, {0x00013, 10}, + {0x00017, 11}, {0x00017, 11}, {0x00018, 11}, {0x00018, 11}, + {0x00108, 11}, {0x00108, 11}, {0x00902, 11}, {0x00902, 11}, + {0x10302, 11}, {0x10302, 11}, {0x10402, 11}, {0x10402, 11}, + {0x10f01, 11}, {0x10f01, 11}, {0x11001, 11}, {0x11001, 11}, + {0x00019, 12}, {0x0001a, 12}, {0x0001b, 12}, {0x00109, 12}, + {0x00603, 12}, {0x0010a, 12}, {0x00205, 12}, {0x00703, 12}, + {0x00e01, 12}, {0x10008, 12}, {0x10502, 12}, {0x10602, 12}, + {0x11101, 12}, {0x11201, 12}, {0x11301, 12}, {0x11401, 12}, + {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, + {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, + {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, + {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, + {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, + {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, + {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, + {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7}, {0x01bff, 7} +}; + static short const dc_threshold[] = { - 21514, 26984, 8307, 28531, 29798, 24951, 25970, 26912, - 8307, 25956, 26994, 25974, 8292, 29286, 28015, 29728, - 25960, 18208, 21838, 18208, 19536, 22560, 26998, 8260, - 28515, 25956, 8291, 25640, 30309, 27749, 11817, 22794, - 30063, 8306, 28531, 29798, 24951, 25970, 25632, 29545, - 29300, 25193, 29813, 29295, 26656, 29537, 29728, 8303, - 26983, 25974, 24864, 25443, 29541, 8307, 28532, 26912, - 29556, 29472, 30063, 25458, 8293, 28515, 25956, 2606 + 26708, 29545, 25120, 28265, 29281, 8313, 29557, 29541, + 18208, 21838, 18208, 19536, 29472, 26223, 30580, 29281, + 8293, 25956, 26994, 25974, 8292, 29286, 28015, 22560, + 18774, 8260, 20557, 18245, 8244, 26664, 29812, 14960, + 12079, 30583, 11895, 30328, 25705, 28462, 26482, 29472, + 30063, 25458, 29541, 8233, 29505, 8299, 28518, 8306, + 26740, 8293, 28531, 29301, 25955, 8307, 28532, 31008, + 30063, 8306, 26980, 29811, 26994, 30050, 28532, 2674 +}; + + +static VLC const ERRtab[] = { + {VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0}, + {VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0}, + {VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0}, + {VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0}, + {VLC_ERROR, 0}, {VLC_ERROR, 0}, {VLC_ERROR, 0} }; static VLC const dc_lum_tab[] = {