1c888fe027c338f337123de4da2de1ac73b0f7587Christian König/************************************************************************** 2c888fe027c338f337123de4da2de1ac73b0f7587Christian König * 39765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König * Copyright 2011 Maarten Lankhorst 49765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König * Copyright 2011 Christian König 5c888fe027c338f337123de4da2de1ac73b0f7587Christian König * All Rights Reserved. 6c888fe027c338f337123de4da2de1ac73b0f7587Christian König * 7c888fe027c338f337123de4da2de1ac73b0f7587Christian König * Permission is hereby granted, free of charge, to any person obtaining a 8c888fe027c338f337123de4da2de1ac73b0f7587Christian König * copy of this software and associated documentation files (the 9c888fe027c338f337123de4da2de1ac73b0f7587Christian König * "Software"), to deal in the Software without restriction, including 10c888fe027c338f337123de4da2de1ac73b0f7587Christian König * without limitation the rights to use, copy, modify, merge, publish, 11c888fe027c338f337123de4da2de1ac73b0f7587Christian König * distribute, sub license, and/or sell copies of the Software, and to 12c888fe027c338f337123de4da2de1ac73b0f7587Christian König * permit persons to whom the Software is furnished to do so, subject to 13c888fe027c338f337123de4da2de1ac73b0f7587Christian König * the following conditions: 14c888fe027c338f337123de4da2de1ac73b0f7587Christian König * 15c888fe027c338f337123de4da2de1ac73b0f7587Christian König * The above copyright notice and this permission notice (including the 16c888fe027c338f337123de4da2de1ac73b0f7587Christian König * next paragraph) shall be included in all copies or substantial portions 17c888fe027c338f337123de4da2de1ac73b0f7587Christian König * of the Software. 18c888fe027c338f337123de4da2de1ac73b0f7587Christian König * 19c888fe027c338f337123de4da2de1ac73b0f7587Christian König * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20c888fe027c338f337123de4da2de1ac73b0f7587Christian König * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21c888fe027c338f337123de4da2de1ac73b0f7587Christian König * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 22c888fe027c338f337123de4da2de1ac73b0f7587Christian König * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 23c888fe027c338f337123de4da2de1ac73b0f7587Christian König * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24c888fe027c338f337123de4da2de1ac73b0f7587Christian König * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25c888fe027c338f337123de4da2de1ac73b0f7587Christian König * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26c888fe027c338f337123de4da2de1ac73b0f7587Christian König * 27c888fe027c338f337123de4da2de1ac73b0f7587Christian König **************************************************************************/ 28c888fe027c338f337123de4da2de1ac73b0f7587Christian König 2919bcd21ed151cf1716f2f87dff0f712231aa2ce7Kai Wasserbäch#include "pipe/p_video_decoder.h" 3019bcd21ed151cf1716f2f87dff0f712231aa2ce7Kai Wasserbäch#include "util/u_memory.h" 31c888fe027c338f337123de4da2de1ac73b0f7587Christian König 32c888fe027c338f337123de4da2de1ac73b0f7587Christian König#include "vl_vlc.h" 33c888fe027c338f337123de4da2de1ac73b0f7587Christian König#include "vl_mpeg12_bitstream.h" 34c888fe027c338f337123de4da2de1ac73b0f7587Christian König 359765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königenum { 369765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König dct_End_of_Block = 0xFF, 379765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König dct_Escape = 0xFE, 389765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König dct_DC = 0xFD, 399765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König dct_AC = 0xFC 40c888fe027c338f337123de4da2de1ac73b0f7587Christian König}; 41c888fe027c338f337123de4da2de1ac73b0f7587Christian König 429765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstruct dct_coeff 439765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König{ 449765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König uint8_t length; 459765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König uint8_t run; 469765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König int16_t level; 47c888fe027c338f337123de4da2de1ac73b0f7587Christian König}; 48c888fe027c338f337123de4da2de1ac73b0f7587Christian König 499765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstruct dct_coeff_compressed 509765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König{ 519765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König uint32_t bitcode; 529765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König struct dct_coeff coeff; 53c888fe027c338f337123de4da2de1ac73b0f7587Christian König}; 54c888fe027c338f337123de4da2de1ac73b0f7587Christian König 559765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König/* coding table as found in the spec annex B.5 table B-1 */ 569765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic const struct vl_vlc_compressed macroblock_address_increment[] = { 579765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x8000, { 1, 1 } }, 589765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x6000, { 3, 2 } }, 599765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x4000, { 3, 3 } }, 609765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x3000, { 4, 4 } }, 619765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2000, { 4, 5 } }, 629765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1800, { 5, 6 } }, 639765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1000, { 5, 7 } }, 649765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0e00, { 7, 8 } }, 659765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0c00, { 7, 9 } }, 669765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0b00, { 8, 10 } }, 679765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0a00, { 8, 11 } }, 689765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0900, { 8, 12 } }, 699765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0800, { 8, 13 } }, 709765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0700, { 8, 14 } }, 719765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0600, { 8, 15 } }, 729765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x05c0, { 10, 16 } }, 739765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0580, { 10, 17 } }, 749765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0540, { 10, 18 } }, 759765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0500, { 10, 19 } }, 769765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x04c0, { 10, 20 } }, 779765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0480, { 10, 21 } }, 789765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0460, { 11, 22 } }, 799765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0440, { 11, 23 } }, 809765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0420, { 11, 24 } }, 819765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0400, { 11, 25 } }, 829765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x03e0, { 11, 26 } }, 839765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x03c0, { 11, 27 } }, 849765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x03a0, { 11, 28 } }, 859765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0380, { 11, 29 } }, 869765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0360, { 11, 30 } }, 879765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0340, { 11, 31 } }, 889765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0320, { 11, 32 } }, 899765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0300, { 11, 33 } } 90c888fe027c338f337123de4da2de1ac73b0f7587Christian König}; 91c888fe027c338f337123de4da2de1ac73b0f7587Christian König 929765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König#define Q PIPE_MPEG12_MB_TYPE_QUANT 939765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König#define F PIPE_MPEG12_MB_TYPE_MOTION_FORWARD 949765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König#define B PIPE_MPEG12_MB_TYPE_MOTION_BACKWARD 959765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König#define P PIPE_MPEG12_MB_TYPE_PATTERN 969765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König#define I PIPE_MPEG12_MB_TYPE_INTRA 97c888fe027c338f337123de4da2de1ac73b0f7587Christian König 989765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König/* coding table as found in the spec annex B.5 table B-2 */ 999765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic const struct vl_vlc_compressed macroblock_type_i[] = { 1009765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x8000, { 1, I } }, 1019765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x4000, { 2, Q|I } } 102c888fe027c338f337123de4da2de1ac73b0f7587Christian König}; 103c888fe027c338f337123de4da2de1ac73b0f7587Christian König 1049765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König/* coding table as found in the spec annex B.5 table B-3 */ 1059765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic const struct vl_vlc_compressed macroblock_type_p[] = { 1069765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x8000, { 1, F|P } }, 1079765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x4000, { 2, P } }, 1089765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2000, { 3, F } }, 1099765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1800, { 5, I } }, 1109765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1000, { 5, Q|F|P } }, 1119765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0800, { 5, Q|P } }, 1129765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0400, { 6, Q|I } } 113c888fe027c338f337123de4da2de1ac73b0f7587Christian König}; 114c888fe027c338f337123de4da2de1ac73b0f7587Christian König 1159765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König/* coding table as found in the spec annex B.5 table B-4 */ 1169765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic const struct vl_vlc_compressed macroblock_type_b[] = { 1179765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x8000, { 2, F|B } }, 1189765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xC000, { 2, F|B|P } }, 1199765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x4000, { 3, B } }, 1209765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x6000, { 3, B|P } }, 1219765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2000, { 4, F } }, 1229765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x3000, { 4, F|P } }, 1239765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1800, { 5, I } }, 1249765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1000, { 5, Q|F|B|P } }, 1259765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0C00, { 6, Q|F|P } }, 1269765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0800, { 6, Q|B|P } }, 1279765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0400, { 6, Q|I } } 128c888fe027c338f337123de4da2de1ac73b0f7587Christian König}; 129c888fe027c338f337123de4da2de1ac73b0f7587Christian König 1309765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König#undef Q 1319765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König#undef F 1329765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König#undef B 1339765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König#undef P 1349765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König#undef I 1359765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König 1369765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König/* coding table as found in the spec annex B.5 table B-9 */ 1379765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic const struct vl_vlc_compressed coded_block_pattern[] = { 1389765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xE000, { 3, 60 } }, 1399765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xD000, { 4, 4 } }, 1409765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xC000, { 4, 8 } }, 1419765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xB000, { 4, 16 } }, 1429765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xA000, { 4, 32 } }, 1439765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x9800, { 5, 12 } }, 1449765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x9000, { 5, 48 } }, 1459765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x8800, { 5, 20 } }, 1469765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x8000, { 5, 40 } }, 1479765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x7800, { 5, 28 } }, 1489765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x7000, { 5, 44 } }, 1499765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x6800, { 5, 52 } }, 1509765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x6000, { 5, 56 } }, 1519765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x5800, { 5, 1 } }, 1529765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x5000, { 5, 61 } }, 1539765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x4800, { 5, 2 } }, 1549765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x4000, { 5, 62 } }, 1559765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x3C00, { 6, 24 } }, 1569765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x3800, { 6, 36 } }, 1579765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x3400, { 6, 3 } }, 1589765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x3000, { 6, 63 } }, 1599765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2E00, { 7, 5 } }, 1609765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2C00, { 7, 9 } }, 1619765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2A00, { 7, 17 } }, 1629765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2800, { 7, 33 } }, 1639765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2600, { 7, 6 } }, 1649765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2400, { 7, 10 } }, 1659765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2200, { 7, 18 } }, 1669765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2000, { 7, 34 } }, 1679765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1F00, { 8, 7 } }, 1689765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1E00, { 8, 11 } }, 1699765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1D00, { 8, 19 } }, 1709765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1C00, { 8, 35 } }, 1719765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1B00, { 8, 13 } }, 1729765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1A00, { 8, 49 } }, 1739765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1900, { 8, 21 } }, 1749765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1800, { 8, 41 } }, 1759765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1700, { 8, 14 } }, 1769765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1600, { 8, 50 } }, 1779765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1500, { 8, 22 } }, 1789765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1400, { 8, 42 } }, 1799765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1300, { 8, 15 } }, 1809765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1200, { 8, 51 } }, 1819765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1100, { 8, 23 } }, 1829765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1000, { 8, 43 } }, 1839765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0F00, { 8, 25 } }, 1849765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0E00, { 8, 37 } }, 1859765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0D00, { 8, 26 } }, 1869765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0C00, { 8, 38 } }, 1879765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0B00, { 8, 29 } }, 1889765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0A00, { 8, 45 } }, 1899765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0900, { 8, 53 } }, 1909765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0800, { 8, 57 } }, 1919765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0700, { 8, 30 } }, 1929765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0600, { 8, 46 } }, 1939765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0500, { 8, 54 } }, 1949765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0400, { 8, 58 } }, 1959765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0380, { 9, 31 } }, 1969765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0300, { 9, 47 } }, 1979765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0280, { 9, 55 } }, 1989765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0200, { 9, 59 } }, 1999765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0180, { 9, 27 } }, 2009765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0100, { 9, 39 } }, 2019765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0080, { 9, 0 } } 202c888fe027c338f337123de4da2de1ac73b0f7587Christian König}; 203c888fe027c338f337123de4da2de1ac73b0f7587Christian König 2049765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König/* coding table as found in the spec annex B.5 table B-10 */ 2059765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic const struct vl_vlc_compressed motion_code[] = { 2069765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0320, { 11, -16 } }, 2079765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0360, { 11, -15 } }, 2089765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x03a0, { 11, -14 } }, 2099765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x03e0, { 11, -13 } }, 2109765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0420, { 11, -12 } }, 2119765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0460, { 11, -11 } }, 2129765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x04c0, { 10, -10 } }, 2139765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0540, { 10, -9 } }, 2149765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x05c0, { 10, -8 } }, 2159765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0700, { 8, -7 } }, 2169765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0900, { 8, -6 } }, 2179765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0b00, { 8, -5 } }, 2189765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0e00, { 7, -4 } }, 2199765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1800, { 5, -3 } }, 2209765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x3000, { 4, -2 } }, 2219765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x6000, { 3, -1 } }, 2229765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x8000, { 1, 0 } }, 2239765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x4000, { 3, 1 } }, 2249765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2000, { 4, 2 } }, 2259765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1000, { 5, 3 } }, 2269765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0c00, { 7, 4 } }, 2279765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0a00, { 8, 5 } }, 2289765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0800, { 8, 6 } }, 2299765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0600, { 8, 7 } }, 2309765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0580, { 10, 8 } }, 2319765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0500, { 10, 9 } }, 2329765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0480, { 10, 10 } }, 2339765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0440, { 11, 11 } }, 2349765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0400, { 11, 12 } }, 2359765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x03c0, { 11, 13 } }, 2369765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0380, { 11, 14 } }, 2379765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0340, { 11, 15 } }, 2389765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0300, { 11, 16 } } 239c888fe027c338f337123de4da2de1ac73b0f7587Christian König}; 240c888fe027c338f337123de4da2de1ac73b0f7587Christian König 2419765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König/* coding table as found in the spec annex B.5 table B-11 */ 2429765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic const struct vl_vlc_compressed dmvector[] = { 2439765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0000, { 1, 0 } }, 2449765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x8000, { 2, 1 } }, 2459765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xc000, { 2, -1 } } 246c888fe027c338f337123de4da2de1ac73b0f7587Christian König}; 247c888fe027c338f337123de4da2de1ac73b0f7587Christian König 2489765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König/* coding table as found in the spec annex B.5 table B-12 */ 2499765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic const struct vl_vlc_compressed dct_dc_size_luminance[] = { 2509765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x8000, { 3, 0 } }, 2519765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0000, { 2, 1 } }, 2529765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x4000, { 2, 2 } }, 2539765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xA000, { 3, 3 } }, 2549765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xC000, { 3, 4 } }, 2559765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xE000, { 4, 5 } }, 2569765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xF000, { 5, 6 } }, 2579765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xF800, { 6, 7 } }, 2589765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xFC00, { 7, 8 } }, 2599765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xFE00, { 8, 9 } }, 2609765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xFF00, { 9, 10 } }, 2619765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xFF80, { 9, 11 } } 262c888fe027c338f337123de4da2de1ac73b0f7587Christian König}; 263c888fe027c338f337123de4da2de1ac73b0f7587Christian König 2649765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König/* coding table as found in the spec annex B.5 table B-13 */ 2659765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic const struct vl_vlc_compressed dct_dc_size_chrominance[] = { 2669765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0000, { 2, 0 } }, 2679765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x4000, { 2, 1 } }, 2689765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x8000, { 2, 2 } }, 2699765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xC000, { 3, 3 } }, 2709765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xE000, { 4, 4 } }, 2719765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xF000, { 5, 5 } }, 2729765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xF800, { 6, 6 } }, 2739765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xFC00, { 7, 7 } }, 2749765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xFE00, { 8, 8 } }, 2759765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xFF00, { 9, 9 } }, 2769765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xFF80, { 10, 10 } }, 2779765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xFFC0, { 10, 11 } } 278c888fe027c338f337123de4da2de1ac73b0f7587Christian König}; 279c888fe027c338f337123de4da2de1ac73b0f7587Christian König 2809765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König/* coding table as found in the spec annex B.5 table B-14 */ 2819765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic const struct dct_coeff_compressed dct_coeff_tbl_zero[] = { 2829765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x8000, { 2, dct_End_of_Block, 0 } }, 2839765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x8000, { 1, dct_DC, 1 } }, 2849765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xC000, { 2, dct_AC, 1 } }, 2859765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x6000, { 3, 1, 1 } }, 2869765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x4000, { 4, 0, 2 } }, 2879765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x5000, { 4, 2, 1 } }, 2889765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2800, { 5, 0, 3 } }, 2899765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x3800, { 5, 3, 1 } }, 2909765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x3000, { 5, 4, 1 } }, 2919765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1800, { 6, 1, 2 } }, 2929765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1C00, { 6, 5, 1 } }, 2939765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1400, { 6, 6, 1 } }, 2949765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1000, { 6, 7, 1 } }, 2959765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0C00, { 7, 0, 4 } }, 2969765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0800, { 7, 2, 2 } }, 2979765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0E00, { 7, 8, 1 } }, 2989765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0A00, { 7, 9, 1 } }, 2999765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0400, { 6, dct_Escape, 0 } }, 3009765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2600, { 8, 0, 5 } }, 3019765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2100, { 8, 0, 6 } }, 3029765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2500, { 8, 1, 3 } }, 3039765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2400, { 8, 3, 2 } }, 3049765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2700, { 8, 10, 1 } }, 3059765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2300, { 8, 11, 1 } }, 3069765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2200, { 8, 12, 1 } }, 3079765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2000, { 8, 13, 1 } }, 3089765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0280, { 10, 0, 7 } }, 3099765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0300, { 10, 1, 4 } }, 3109765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x02C0, { 10, 2, 3 } }, 3119765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x03C0, { 10, 4, 2 } }, 3129765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0240, { 10, 5, 2 } }, 3139765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0380, { 10, 14, 1 } }, 3149765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0340, { 10, 15, 1 } }, 3159765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0200, { 10, 16, 1 } }, 3169765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x01D0, { 12, 0, 8 } }, 3179765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0180, { 12, 0, 9 } }, 3189765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0130, { 12, 0, 10 } }, 3199765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0100, { 12, 0, 11 } }, 3209765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x01B0, { 12, 1, 5 } }, 3219765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0140, { 12, 2, 4 } }, 3229765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x01C0, { 12, 3, 3 } }, 3239765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0120, { 12, 4, 3 } }, 3249765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x01E0, { 12, 6, 2 } }, 3259765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0150, { 12, 7, 2 } }, 3269765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0110, { 12, 8, 2 } }, 3279765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x01F0, { 12, 17, 1 } }, 3289765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x01A0, { 12, 18, 1 } }, 3299765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0190, { 12, 19, 1 } }, 3309765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0170, { 12, 20, 1 } }, 3319765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0160, { 12, 21, 1 } }, 3329765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x00D0, { 13, 0, 12 } }, 3339765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x00C8, { 13, 0, 13 } }, 3349765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x00C0, { 13, 0, 14 } }, 3359765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x00B8, { 13, 0, 15 } }, 3369765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x00B0, { 13, 1, 6 } }, 3379765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x00A8, { 13, 1, 7 } }, 3389765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x00A0, { 13, 2, 5 } }, 3399765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0098, { 13, 3, 4 } }, 3409765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0090, { 13, 5, 3 } }, 3419765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0088, { 13, 9, 2 } }, 3429765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0080, { 13, 10, 2 } }, 3439765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x00F8, { 13, 22, 1 } }, 3449765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x00F0, { 13, 23, 1 } }, 3459765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x00E8, { 13, 24, 1 } }, 3469765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x00E0, { 13, 25, 1 } }, 3479765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x00D8, { 13, 26, 1 } }, 3489765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x007C, { 14, 0, 16 } }, 3499765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0078, { 14, 0, 17 } }, 3509765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0074, { 14, 0, 18 } }, 3519765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0070, { 14, 0, 19 } }, 3529765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x006C, { 14, 0, 20 } }, 3539765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0068, { 14, 0, 21 } }, 3549765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0064, { 14, 0, 22 } }, 3559765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0060, { 14, 0, 23 } }, 3569765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x005C, { 14, 0, 24 } }, 3579765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0058, { 14, 0, 25 } }, 3589765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0054, { 14, 0, 26 } }, 3599765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0050, { 14, 0, 27 } }, 3609765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x004C, { 14, 0, 28 } }, 3619765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0048, { 14, 0, 29 } }, 3629765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0044, { 14, 0, 30 } }, 3639765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0040, { 14, 0, 31 } }, 3649765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0030, { 15, 0, 32 } }, 3659765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x002E, { 15, 0, 33 } }, 3669765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x002C, { 15, 0, 34 } }, 3679765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x002A, { 15, 0, 35 } }, 3689765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0028, { 15, 0, 36 } }, 3699765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0026, { 15, 0, 37 } }, 3709765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0024, { 15, 0, 38 } }, 3719765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0022, { 15, 0, 39 } }, 3729765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0020, { 15, 0, 40 } }, 3739765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x003E, { 15, 1, 8 } }, 3749765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x003C, { 15, 1, 9 } }, 3759765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x003A, { 15, 1, 10 } }, 3769765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0038, { 15, 1, 11 } }, 3779765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0036, { 15, 1, 12 } }, 3789765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0034, { 15, 1, 13 } }, 3799765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0032, { 15, 1, 14 } }, 3809765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0013, { 16, 1, 15 } }, 3819765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0012, { 16, 1, 16 } }, 3829765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0011, { 16, 1, 17 } }, 3839765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0010, { 16, 1, 18 } }, 3849765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0014, { 16, 6, 3 } }, 3859765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x001A, { 16, 11, 2 } }, 3869765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0019, { 16, 12, 2 } }, 3879765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0018, { 16, 13, 2 } }, 3889765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0017, { 16, 14, 2 } }, 3899765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0016, { 16, 15, 2 } }, 3909765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0015, { 16, 16, 2 } }, 3919765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x001F, { 16, 27, 1 } }, 3929765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x001E, { 16, 28, 1 } }, 3939765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x001D, { 16, 29, 1 } }, 3949765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x001C, { 16, 30, 1 } }, 3959765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x001B, { 16, 31, 1 } } 396c888fe027c338f337123de4da2de1ac73b0f7587Christian König}; 397c888fe027c338f337123de4da2de1ac73b0f7587Christian König 3989765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König/* coding table as found in the spec annex B.5 table B-15 */ 3999765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic const struct dct_coeff_compressed dct_coeff_tbl_one[] = { 4009765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x6000, { 4, dct_End_of_Block, 0 } }, 4019765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x8000, { 2, 0, 1 } }, 4029765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x4000, { 3, 1, 1 } }, 4039765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xC000, { 3, 0, 2 } }, 4049765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2800, { 5, 2, 1 } }, 4059765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x7000, { 4, 0, 3 } }, 4069765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x3800, { 5, 3, 1 } }, 4079765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1800, { 6, 4, 1 } }, 4089765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x3000, { 5, 1, 2 } }, 4099765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1C00, { 6, 5, 1 } }, 4109765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0C00, { 7, 6, 1 } }, 4119765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0800, { 7, 7, 1 } }, 4129765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xE000, { 5, 0, 4 } }, 4139765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0E00, { 7, 2, 2 } }, 4149765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0A00, { 7, 8, 1 } }, 4159765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xF000, { 7, 9, 1 } }, 4169765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0400, { 6, dct_Escape, 0 } }, 4179765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xE800, { 5, 0, 5 } }, 4189765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1400, { 6, 0, 6 } }, 4199765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xF200, { 7, 1, 3 } }, 4209765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2600, { 8, 3, 2 } }, 4219765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xF400, { 7, 10, 1 } }, 4229765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2100, { 8, 11, 1 } }, 4239765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2500, { 8, 12, 1 } }, 4249765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2400, { 8, 13, 1 } }, 4259765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x1000, { 6, 0, 7 } }, 4269765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2700, { 8, 1, 4 } }, 4279765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xFC00, { 8, 2, 3 } }, 4289765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xFD00, { 8, 4, 2 } }, 4299765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0200, { 9, 5, 2 } }, 4309765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0280, { 9, 14, 1 } }, 4319765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0380, { 9, 15, 1 } }, 4329765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0340, { 10, 16, 1 } }, 4339765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xF600, { 7, 0, 8 } }, 4349765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xF800, { 7, 0, 9 } }, 4359765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2300, { 8, 0, 10 } }, 4369765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2200, { 8, 0, 11 } }, 4379765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x2000, { 8, 1, 5 } }, 4389765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0300, { 10, 2, 4 } }, 4399765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x01C0, { 12, 3, 3 } }, 4409765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0120, { 12, 4, 3 } }, 4419765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x01E0, { 12, 6, 2 } }, 4429765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0150, { 12, 7, 2 } }, 4439765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0110, { 12, 8, 2 } }, 4449765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x01F0, { 12, 17, 1 } }, 4459765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x01A0, { 12, 18, 1 } }, 4469765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0190, { 12, 19, 1 } }, 4479765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0170, { 12, 20, 1 } }, 4489765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0160, { 12, 21, 1 } }, 4499765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xFA00, { 8, 0, 12 } }, 4509765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xFB00, { 8, 0, 13 } }, 4519765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xFE00, { 8, 0, 14 } }, 4529765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0xFF00, { 8, 0, 15 } }, 4539765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x00B0, { 13, 1, 6 } }, 4549765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x00A8, { 13, 1, 7 } }, 4559765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x00A0, { 13, 2, 5 } }, 4569765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0098, { 13, 3, 4 } }, 4579765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0090, { 13, 5, 3 } }, 4589765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0088, { 13, 9, 2 } }, 4599765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0080, { 13, 10, 2 } }, 4609765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x00F8, { 13, 22, 1 } }, 4619765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x00F0, { 13, 23, 1 } }, 4629765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x00E8, { 13, 24, 1 } }, 4639765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x00E0, { 13, 25, 1 } }, 4649765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x00D8, { 13, 26, 1 } }, 4659765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x007C, { 14, 0, 16 } }, 4669765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0078, { 14, 0, 17 } }, 4679765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0074, { 14, 0, 18 } }, 4689765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0070, { 14, 0, 19 } }, 4699765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x006C, { 14, 0, 20 } }, 4709765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0068, { 14, 0, 21 } }, 4719765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0064, { 14, 0, 22 } }, 4729765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0060, { 14, 0, 23 } }, 4739765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x005C, { 14, 0, 24 } }, 4749765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0058, { 14, 0, 25 } }, 4759765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0054, { 14, 0, 26 } }, 4769765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0050, { 14, 0, 27 } }, 4779765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x004C, { 14, 0, 28 } }, 4789765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0048, { 14, 0, 29 } }, 4799765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0044, { 14, 0, 30 } }, 4809765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0040, { 14, 0, 31 } }, 4819765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0030, { 15, 0, 32 } }, 4829765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x002E, { 15, 0, 33 } }, 4839765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x002C, { 15, 0, 34 } }, 4849765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x002A, { 15, 0, 35 } }, 4859765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0028, { 15, 0, 36 } }, 4869765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0026, { 15, 0, 37 } }, 4879765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0024, { 15, 0, 38 } }, 4889765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0022, { 15, 0, 39 } }, 4899765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0020, { 15, 0, 40 } }, 4909765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x003E, { 15, 1, 8 } }, 4919765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x003C, { 15, 1, 9 } }, 4929765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x003A, { 15, 1, 10 } }, 4939765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0038, { 15, 1, 11 } }, 4949765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0036, { 15, 1, 12 } }, 4959765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0034, { 15, 1, 13 } }, 4969765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0032, { 15, 1, 14 } }, 4979765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0013, { 16, 1, 15 } }, 4989765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0012, { 16, 1, 16 } }, 4999765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0011, { 16, 1, 17 } }, 5009765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0010, { 16, 1, 18 } }, 5019765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0014, { 16, 6, 3 } }, 5029765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x001A, { 16, 11, 2 } }, 5039765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0019, { 16, 12, 2 } }, 5049765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0018, { 16, 13, 2 } }, 5059765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0017, { 16, 14, 2 } }, 5069765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0016, { 16, 15, 2 } }, 5079765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x0015, { 16, 16, 2 } }, 5089765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x001F, { 16, 27, 1 } }, 5099765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x001E, { 16, 28, 1 } }, 5109765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x001D, { 16, 29, 1 } }, 5119765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x001C, { 16, 30, 1 } }, 5129765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0x001B, { 16, 31, 1 } } 513c888fe027c338f337123de4da2de1ac73b0f7587Christian König}; 514c888fe027c338f337123de4da2de1ac73b0f7587Christian König 5159765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König/* q_scale_type */ 5169765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic const unsigned quant_scale[2][32] = { 5179765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 5189765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62 }, 5199765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König { 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 18, 20, 22, 24, 5209765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König 28, 32, 36, 40, 44, 48, 52, 56, 64, 72, 80, 88, 96, 104, 112 } 521c888fe027c338f337123de4da2de1ac73b0f7587Christian König}; 522c888fe027c338f337123de4da2de1ac73b0f7587Christian König 5239765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic struct vl_vlc_entry tbl_B1[1 << 11]; 5249765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic struct vl_vlc_entry tbl_B2[1 << 2]; 5259765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic struct vl_vlc_entry tbl_B3[1 << 6]; 5269765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic struct vl_vlc_entry tbl_B4[1 << 6]; 5279765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic struct vl_vlc_entry tbl_B9[1 << 9]; 5289765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic struct vl_vlc_entry tbl_B10[1 << 11]; 5299765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic struct vl_vlc_entry tbl_B11[1 << 2]; 5309765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic struct vl_vlc_entry tbl_B12[1 << 10]; 5319765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic struct vl_vlc_entry tbl_B13[1 << 10]; 5329765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic struct dct_coeff tbl_B14_DC[1 << 17]; 5339765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic struct dct_coeff tbl_B14_AC[1 << 17]; 5349765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic struct dct_coeff tbl_B15[1 << 17]; 535c888fe027c338f337123de4da2de1ac73b0f7587Christian König 5369765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic INLINE void 5379765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königinit_dct_coeff_table(struct dct_coeff *dst, const struct dct_coeff_compressed *src, 5389765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König unsigned size, bool is_DC) 539ce31aaec02de0ef509dcee9d641c39623017a638Christian König{ 5409765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König unsigned i; 541ce31aaec02de0ef509dcee9d641c39623017a638Christian König 5429765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König for (i=0;i<(1<<17);++i) { 5439765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König dst[i].length = 0; 5449765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König dst[i].level = 0; 5459765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König dst[i].run = dct_End_of_Block; 546ce31aaec02de0ef509dcee9d641c39623017a638Christian König } 547c888fe027c338f337123de4da2de1ac73b0f7587Christian König 5489765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König for(; size > 0; --size, ++src) { 5499765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König struct dct_coeff coeff = src->coeff; 5509765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König bool has_sign = true; 551c888fe027c338f337123de4da2de1ac73b0f7587Christian König 5529765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König switch (coeff.run) { 5539765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König case dct_End_of_Block: 5549765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (is_DC) 5559765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König continue; 556c888fe027c338f337123de4da2de1ac73b0f7587Christian König 5579765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König has_sign = false; 5589765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König break; 559c888fe027c338f337123de4da2de1ac73b0f7587Christian König 5609765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König case dct_Escape: 5619765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König has_sign = false; 5629765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König break; 563c888fe027c338f337123de4da2de1ac73b0f7587Christian König 5649765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König case dct_DC: 5659765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (!is_DC) 5669765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König continue; 567c888fe027c338f337123de4da2de1ac73b0f7587Christian König 5689765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König coeff.length += 1; 5699765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König coeff.run = 1; 5709765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König break; 571c888fe027c338f337123de4da2de1ac73b0f7587Christian König 5729765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König case dct_AC: 5739765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (is_DC) 5749765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König continue; 575c888fe027c338f337123de4da2de1ac73b0f7587Christian König 5769765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König coeff.length += 1; 5779765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König coeff.run = 1; 5789765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König break; 579c888fe027c338f337123de4da2de1ac73b0f7587Christian König 5809765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König default: 5819765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König coeff.length += 1; 5829765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König coeff.run += 1; 5839765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König break; 5849765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König } 585c888fe027c338f337123de4da2de1ac73b0f7587Christian König 5869765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König for(i=0; i<(1 << (17 - coeff.length)); ++i) 5879765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König dst[src->bitcode << 1 | i] = coeff; 588c888fe027c338f337123de4da2de1ac73b0f7587Christian König 5899765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (has_sign) { 5909765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König coeff.level = -coeff.level; 5919765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König for(; i<(1 << (18 - coeff.length)); ++i) 5929765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König dst[src->bitcode << 1 | i] = coeff; 593c888fe027c338f337123de4da2de1ac73b0f7587Christian König } 594c888fe027c338f337123de4da2de1ac73b0f7587Christian König } 595c888fe027c338f337123de4da2de1ac73b0f7587Christian König} 596c888fe027c338f337123de4da2de1ac73b0f7587Christian König 5979765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic INLINE void 5989765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königinit_tables() 599c888fe027c338f337123de4da2de1ac73b0f7587Christian König{ 6009765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König vl_vlc_init_table(tbl_B1, Elements(tbl_B1), macroblock_address_increment, Elements(macroblock_address_increment)); 6019765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König vl_vlc_init_table(tbl_B2, Elements(tbl_B2), macroblock_type_i, Elements(macroblock_type_i)); 6029765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König vl_vlc_init_table(tbl_B3, Elements(tbl_B3), macroblock_type_p, Elements(macroblock_type_p)); 6039765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König vl_vlc_init_table(tbl_B4, Elements(tbl_B4), macroblock_type_b, Elements(macroblock_type_b)); 6049765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König vl_vlc_init_table(tbl_B9, Elements(tbl_B9), coded_block_pattern, Elements(coded_block_pattern)); 6059765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König vl_vlc_init_table(tbl_B10, Elements(tbl_B10), motion_code, Elements(motion_code)); 6069765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König vl_vlc_init_table(tbl_B11, Elements(tbl_B11), dmvector, Elements(dmvector)); 6079765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König vl_vlc_init_table(tbl_B12, Elements(tbl_B12), dct_dc_size_luminance, Elements(dct_dc_size_luminance)); 6089765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König vl_vlc_init_table(tbl_B13, Elements(tbl_B13), dct_dc_size_chrominance, Elements(dct_dc_size_chrominance)); 6099765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König init_dct_coeff_table(tbl_B14_DC, dct_coeff_tbl_zero, Elements(dct_coeff_tbl_zero), true); 6109765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König init_dct_coeff_table(tbl_B14_AC, dct_coeff_tbl_zero, Elements(dct_coeff_tbl_zero), false); 6119765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König init_dct_coeff_table(tbl_B15, dct_coeff_tbl_one, Elements(dct_coeff_tbl_one), false); 612c888fe027c338f337123de4da2de1ac73b0f7587Christian König} 613c888fe027c338f337123de4da2de1ac73b0f7587Christian König 61449967950a56de276ffcbaea80acbc9f5bd3207bcVinson Leestatic INLINE int 6159765dede7556f7ccfef1d90bab14a2bfa03384e5Christian KönigDIV2DOWN(int todiv) 616c888fe027c338f337123de4da2de1ac73b0f7587Christian König{ 6179765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König return (todiv&~1)/2; 618c888fe027c338f337123de4da2de1ac73b0f7587Christian König} 619c888fe027c338f337123de4da2de1ac73b0f7587Christian König 62049967950a56de276ffcbaea80acbc9f5bd3207bcVinson Leestatic INLINE int 6219765dede7556f7ccfef1d90bab14a2bfa03384e5Christian KönigDIV2UP(int todiv) 622c888fe027c338f337123de4da2de1ac73b0f7587Christian König{ 6239765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König return (todiv+1)/2; 624c888fe027c338f337123de4da2de1ac73b0f7587Christian König} 625c888fe027c338f337123de4da2de1ac73b0f7587Christian König 6269765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königstatic INLINE void 6279765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königmotion_vector(struct vl_mpg12_bs *bs, int r, int s, int dmv, short delta[2], short dmvector[2]) 628c888fe027c338f337123de4da2de1ac73b0f7587Christian König{ 6299765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König int t; 6309765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König for (t = 0; t < 2; ++t) { 6319765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König int motion_code; 6328ea416f35de0c664ef47b71841756758f22d7faaChristian König int r_size = bs->desc->f_code[s][t]; 6339765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König 6349765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König vl_vlc_fillbits(&bs->vlc); 6359765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König motion_code = vl_vlc_get_vlclbf(&bs->vlc, tbl_B10, 11); 6369765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König 6379765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König assert(r_size >= 0); 6389765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (r_size && motion_code) { 6399765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König int residual = vl_vlc_get_uimsbf(&bs->vlc, r_size) + 1; 6409765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König delta[t] = ((abs(motion_code) - 1) << r_size) + residual; 6419765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (motion_code < 0) 6429765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König delta[t] = -delta[t]; 6439765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König } else 6449765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König delta[t] = motion_code; 6459765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (dmv) 6469765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König dmvector[t] = vl_vlc_get_vlclbf(&bs->vlc, tbl_B11, 2); 647c888fe027c338f337123de4da2de1ac73b0f7587Christian König } 648c888fe027c338f337123de4da2de1ac73b0f7587Christian König} 649c888fe027c338f337123de4da2de1ac73b0f7587Christian König 65049967950a56de276ffcbaea80acbc9f5bd3207bcVinson Leestatic INLINE int 6519765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königwrap(short f, int shift) 652c888fe027c338f337123de4da2de1ac73b0f7587Christian König{ 6539765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (f < (-16 << shift)) 6549765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König return f + (32 << shift); 6559765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König else if (f >= 16 << shift) 6569765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König return f - (32 << shift); 6579765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König else 6589765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König return f; 659c888fe027c338f337123de4da2de1ac73b0f7587Christian König} 660c888fe027c338f337123de4da2de1ac73b0f7587Christian König 66149967950a56de276ffcbaea80acbc9f5bd3207bcVinson Leestatic INLINE void 6629765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königmotion_vector_frame(struct vl_mpg12_bs *bs, int s, struct pipe_mpeg12_macroblock *mb) 663c888fe027c338f337123de4da2de1ac73b0f7587Christian König{ 6649765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König int dmv = mb->macroblock_modes.bits.frame_motion_type == PIPE_MPEG12_MO_TYPE_DUAL_PRIME; 6659765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König short dmvector[2], delta[2]; 666c888fe027c338f337123de4da2de1ac73b0f7587Christian König 6679765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (mb->macroblock_modes.bits.frame_motion_type == PIPE_MPEG12_MO_TYPE_FIELD) { 6689765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb->motion_vertical_field_select |= vl_vlc_get_uimsbf(&bs->vlc, 1) << s; 6699765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König motion_vector(bs, 0, s, dmv, delta, dmvector); 6708ea416f35de0c664ef47b71841756758f22d7faaChristian König mb->PMV[0][s][0] = wrap(mb->PMV[0][s][0] + delta[0], bs->desc->f_code[s][0]); 6718ea416f35de0c664ef47b71841756758f22d7faaChristian König mb->PMV[0][s][1] = wrap(DIV2DOWN(mb->PMV[0][s][1]) + delta[1], bs->desc->f_code[s][1]) * 2; 672c888fe027c338f337123de4da2de1ac73b0f7587Christian König 6739765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb->motion_vertical_field_select |= vl_vlc_get_uimsbf(&bs->vlc, 1) << (s + 2); 6749765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König motion_vector(bs, 1, s, dmv, delta, dmvector); 6758ea416f35de0c664ef47b71841756758f22d7faaChristian König mb->PMV[1][s][0] = wrap(mb->PMV[1][s][0] + delta[0], bs->desc->f_code[s][0]); 6768ea416f35de0c664ef47b71841756758f22d7faaChristian König mb->PMV[1][s][1] = wrap(DIV2DOWN(mb->PMV[1][s][1]) + delta[1], bs->desc->f_code[s][1]) * 2; 677c888fe027c338f337123de4da2de1ac73b0f7587Christian König 6789765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König } else { 6799765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König motion_vector(bs, 0, s, dmv, delta, dmvector); 6808ea416f35de0c664ef47b71841756758f22d7faaChristian König mb->PMV[0][s][0] = wrap(mb->PMV[0][s][0] + delta[0], bs->desc->f_code[s][0]); 6818ea416f35de0c664ef47b71841756758f22d7faaChristian König mb->PMV[0][s][1] = wrap(mb->PMV[0][s][1] + delta[1], bs->desc->f_code[s][1]); 682c888fe027c338f337123de4da2de1ac73b0f7587Christian König } 683c888fe027c338f337123de4da2de1ac73b0f7587Christian König} 684c888fe027c338f337123de4da2de1ac73b0f7587Christian König 68549967950a56de276ffcbaea80acbc9f5bd3207bcVinson Leestatic INLINE void 6869765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königmotion_vector_field(struct vl_mpg12_bs *bs, int s, struct pipe_mpeg12_macroblock *mb) 687c888fe027c338f337123de4da2de1ac73b0f7587Christian König{ 6889765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König int dmv = mb->macroblock_modes.bits.field_motion_type == PIPE_MPEG12_MO_TYPE_DUAL_PRIME; 6899765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König short dmvector[2], delta[2]; 690c888fe027c338f337123de4da2de1ac73b0f7587Christian König 6919765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (mb->macroblock_modes.bits.field_motion_type == PIPE_MPEG12_MO_TYPE_16x8) { 6929765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb->motion_vertical_field_select |= vl_vlc_get_uimsbf(&bs->vlc, 1) << s; 6939765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König motion_vector(bs, 0, s, dmv, delta, dmvector); 694c888fe027c338f337123de4da2de1ac73b0f7587Christian König 6959765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb->motion_vertical_field_select |= vl_vlc_get_uimsbf(&bs->vlc, 1) << (s + 2); 6969765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König motion_vector(bs, 1, s, dmv, delta, dmvector); 6979765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König } else { 6989765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (!dmv) 6999765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb->motion_vertical_field_select |= vl_vlc_get_uimsbf(&bs->vlc, 1) << s; 7009765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König motion_vector(bs, 0, s, dmv, delta, dmvector); 701c888fe027c338f337123de4da2de1ac73b0f7587Christian König } 702c888fe027c338f337123de4da2de1ac73b0f7587Christian König} 703c888fe027c338f337123de4da2de1ac73b0f7587Christian König 70449967950a56de276ffcbaea80acbc9f5bd3207bcVinson Leestatic INLINE void 7059765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königreset_predictor(struct vl_mpg12_bs *bs) { 7069765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König bs->pred_dc[0] = bs->pred_dc[1] = bs->pred_dc[2] = 0; 707c888fe027c338f337123de4da2de1ac73b0f7587Christian König} 708c888fe027c338f337123de4da2de1ac73b0f7587Christian König 70949967950a56de276ffcbaea80acbc9f5bd3207bcVinson Leestatic INLINE void 7109765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königdecode_dct(struct vl_mpg12_bs *bs, struct pipe_mpeg12_macroblock *mb, int scale) 711c888fe027c338f337123de4da2de1ac73b0f7587Christian König{ 7129765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König static const unsigned blk2cc[] = { 0, 0, 0, 0, 1, 2 }; 7139765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König static const struct vl_vlc_entry *blk2dcsize[] = { 7149765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König tbl_B12, tbl_B12, tbl_B12, tbl_B12, tbl_B13, tbl_B13 7159765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König }; 716c888fe027c338f337123de4da2de1ac73b0f7587Christian König 7179765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König bool intra = mb->macroblock_type & PIPE_MPEG12_MB_TYPE_INTRA; 7189765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König const struct dct_coeff *table = intra ? bs->intra_dct_tbl : tbl_B14_AC; 7199765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König const struct dct_coeff *entry; 7209765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König int i, cbp, blk = 0; 7219765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König short *dst = mb->blocks; 722c888fe027c338f337123de4da2de1ac73b0f7587Christian König 7239765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König vl_vlc_fillbits(&bs->vlc); 7249765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb->coded_block_pattern = cbp = intra ? 0x3F : vl_vlc_get_vlclbf(&bs->vlc, tbl_B9, 9); 725c888fe027c338f337123de4da2de1ac73b0f7587Christian König 7269765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König goto entry; 727c888fe027c338f337123de4da2de1ac73b0f7587Christian König 7289765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König while(1) { 7299765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König vl_vlc_eatbits(&bs->vlc, entry->length); 7309765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (entry->run == dct_End_of_Block) { 731c888fe027c338f337123de4da2de1ac73b0f7587Christian König 7329765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König dst += 64; 7339765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König cbp <<= 1; 7349765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König cbp &= 0x3F; 7359765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König blk++; 736c888fe027c338f337123de4da2de1ac73b0f7587Christian König 7379765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königentry: 7389765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (!cbp) 7399765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König break; 740c888fe027c338f337123de4da2de1ac73b0f7587Christian König 7419765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König while(!(cbp & 0x20)) { 7429765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König cbp <<= 1; 7439765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König blk++; 744c888fe027c338f337123de4da2de1ac73b0f7587Christian König } 745c888fe027c338f337123de4da2de1ac73b0f7587Christian König 7469765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König vl_vlc_fillbits(&bs->vlc); 747c888fe027c338f337123de4da2de1ac73b0f7587Christian König 7489765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (intra) { 7499765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König unsigned cc = blk2cc[blk]; 7509765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König unsigned size = vl_vlc_get_vlclbf(&bs->vlc, blk2dcsize[blk], 10); 751c888fe027c338f337123de4da2de1ac73b0f7587Christian König 7529765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (size) { 7539765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König int dct_diff = vl_vlc_get_uimsbf(&bs->vlc, size); 7549765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König int half_range = 1 << (size - 1); 7559765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (dct_diff < half_range) 7569765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König dct_diff = (dct_diff + 1) - (2 * half_range); 7579765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König bs->pred_dc[cc] += dct_diff; 7589765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König } 759c888fe027c338f337123de4da2de1ac73b0f7587Christian König 7609765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König dst[0] = bs->pred_dc[cc]; 7619765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König i = 0; 762c888fe027c338f337123de4da2de1ac73b0f7587Christian König 7639765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König } else { 7649765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König entry = tbl_B14_DC + vl_vlc_peekbits(&bs->vlc, 17); 7659765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König i = -1; 7669765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König continue; 767c888fe027c338f337123de4da2de1ac73b0f7587Christian König } 768c888fe027c338f337123de4da2de1ac73b0f7587Christian König 7699765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König } else if (entry->run == dct_Escape) { 7709765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König i += vl_vlc_get_uimsbf(&bs->vlc, 6) + 1; 7719765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (i > 64) 7729765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König break; 773c888fe027c338f337123de4da2de1ac73b0f7587Christian König 7749765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König dst[i] = vl_vlc_get_simsbf(&bs->vlc, 12) * scale; 775c888fe027c338f337123de4da2de1ac73b0f7587Christian König 7769765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König } else { 7779765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König i += entry->run; 7789765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (i > 64) 7799765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König break; 780c888fe027c338f337123de4da2de1ac73b0f7587Christian König 7819765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König dst[i] = entry->level * scale; 782c888fe027c338f337123de4da2de1ac73b0f7587Christian König } 783c888fe027c338f337123de4da2de1ac73b0f7587Christian König 7849765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König vl_vlc_fillbits(&bs->vlc); 7859765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König entry = table + vl_vlc_peekbits(&bs->vlc, 17); 786c888fe027c338f337123de4da2de1ac73b0f7587Christian König } 787c888fe027c338f337123de4da2de1ac73b0f7587Christian König} 788c888fe027c338f337123de4da2de1ac73b0f7587Christian König 789efa93ae449b6dc8437ee7240a8ea050a0d1699e0Maarten Lankhorststatic INLINE void 7908ea416f35de0c664ef47b71841756758f22d7faaChristian Königdecode_slice(struct vl_mpg12_bs *bs, struct pipe_video_buffer *target) 791c888fe027c338f337123de4da2de1ac73b0f7587Christian König{ 792b59715b13afa6885fe7950677df3be2fd89dee47Brian Paul struct pipe_mpeg12_macroblock mb; 7939765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König short dct_blocks[64*6]; 7949765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König unsigned dct_scale; 7959765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König signed x = -1; 796a9b1c4fe2e67c5b158056a05cbc394d62c1d3e40Christian König 797b59715b13afa6885fe7950677df3be2fd89dee47Brian Paul memset(&mb, 0, sizeof(mb)); 7989765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.base.codec = PIPE_VIDEO_CODEC_MPEG12; 7999765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.y = vl_vlc_get_uimsbf(&bs->vlc, 8) - 1; 8009765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.blocks = dct_blocks; 801a9b1c4fe2e67c5b158056a05cbc394d62c1d3e40Christian König 8029765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König reset_predictor(bs); 803efa93ae449b6dc8437ee7240a8ea050a0d1699e0Maarten Lankhorst vl_vlc_fillbits(&bs->vlc); 8048ea416f35de0c664ef47b71841756758f22d7faaChristian König dct_scale = quant_scale[bs->desc->q_scale_type][vl_vlc_get_uimsbf(&bs->vlc, 5)]; 805c888fe027c338f337123de4da2de1ac73b0f7587Christian König 8069765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (vl_vlc_get_uimsbf(&bs->vlc, 1)) 8079765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König while (vl_vlc_get_uimsbf(&bs->vlc, 9) & 1) 8089765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König vl_vlc_fillbits(&bs->vlc); 8093b773d06d2edd39ce6e6ab6e306e3cca121dddfcChristian König 810d4bbdbd03893e900d8bcf0b46e8307a877d1a3aeChristian König vl_vlc_fillbits(&bs->vlc); 811efa93ae449b6dc8437ee7240a8ea050a0d1699e0Maarten Lankhorst assert(vl_vlc_bits_left(&bs->vlc) > 23 && vl_vlc_peekbits(&bs->vlc, 23)); 8129765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König do { 8139765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König int inc = 0; 814c888fe027c338f337123de4da2de1ac73b0f7587Christian König 815efa93ae449b6dc8437ee7240a8ea050a0d1699e0Maarten Lankhorst if (bs->decoder->profile == PIPE_VIDEO_PROFILE_MPEG1) 816efa93ae449b6dc8437ee7240a8ea050a0d1699e0Maarten Lankhorst while (vl_vlc_peekbits(&bs->vlc, 11) == 15) { 817efa93ae449b6dc8437ee7240a8ea050a0d1699e0Maarten Lankhorst vl_vlc_eatbits(&bs->vlc, 11); 818efa93ae449b6dc8437ee7240a8ea050a0d1699e0Maarten Lankhorst vl_vlc_fillbits(&bs->vlc); 819efa93ae449b6dc8437ee7240a8ea050a0d1699e0Maarten Lankhorst } 820c888fe027c338f337123de4da2de1ac73b0f7587Christian König 8219765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König while (vl_vlc_peekbits(&bs->vlc, 11) == 8) { 8229765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König vl_vlc_eatbits(&bs->vlc, 11); 8239765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König vl_vlc_fillbits(&bs->vlc); 8249765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König inc += 33; 8259765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König } 8269765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König inc += vl_vlc_get_vlclbf(&bs->vlc, tbl_B1, 11); 8279765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (x != -1) { 82885dbb227964d5533a497dbda4803fdf43ad9567fChristian König if (!inc) 82985dbb227964d5533a497dbda4803fdf43ad9567fChristian König return; 8309765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.num_skipped_macroblocks = inc - 1; 8318ea416f35de0c664ef47b71841756758f22d7faaChristian König bs->decoder->decode_macroblock(bs->decoder, target, &bs->desc->base, &mb.base, 1); 8329765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König } 8339765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.x = x += inc; 834c888fe027c338f337123de4da2de1ac73b0f7587Christian König 8358ea416f35de0c664ef47b71841756758f22d7faaChristian König switch (bs->desc->picture_coding_type) { 8369765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König case PIPE_MPEG12_PICTURE_CODING_TYPE_I: 8379765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.macroblock_type = vl_vlc_get_vlclbf(&bs->vlc, tbl_B2, 2); 8389765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König break; 839c888fe027c338f337123de4da2de1ac73b0f7587Christian König 8409765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König case PIPE_MPEG12_PICTURE_CODING_TYPE_P: 8419765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.macroblock_type = vl_vlc_get_vlclbf(&bs->vlc, tbl_B3, 6); 8429765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König break; 843c888fe027c338f337123de4da2de1ac73b0f7587Christian König 8449765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König case PIPE_MPEG12_PICTURE_CODING_TYPE_B: 8459765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.macroblock_type = vl_vlc_get_vlclbf(&bs->vlc, tbl_B4, 6); 846c888fe027c338f337123de4da2de1ac73b0f7587Christian König break; 847c888fe027c338f337123de4da2de1ac73b0f7587Christian König 848c888fe027c338f337123de4da2de1ac73b0f7587Christian König default: 8499765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.macroblock_type = 0; 8509765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König /* dumb gcc */ 8519765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König assert(0); 8529765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König } 8533b773d06d2edd39ce6e6ab6e306e3cca121dddfcChristian König 8549765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.macroblock_modes.value = 0; 8559765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (mb.macroblock_type & (PIPE_MPEG12_MB_TYPE_MOTION_FORWARD | PIPE_MPEG12_MB_TYPE_MOTION_BACKWARD)) { 8568ea416f35de0c664ef47b71841756758f22d7faaChristian König if (bs->desc->picture_structure == PIPE_MPEG12_PICTURE_STRUCTURE_FRAME) { 8578ea416f35de0c664ef47b71841756758f22d7faaChristian König if (bs->desc->frame_pred_frame_dct == 0) 8589765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.macroblock_modes.bits.frame_motion_type = vl_vlc_get_uimsbf(&bs->vlc, 2); 8599765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König else 8609765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.macroblock_modes.bits.frame_motion_type = 2; 8619765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König } else 8629765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.macroblock_modes.bits.field_motion_type = vl_vlc_get_uimsbf(&bs->vlc, 2); 863c888fe027c338f337123de4da2de1ac73b0f7587Christian König 8648ea416f35de0c664ef47b71841756758f22d7faaChristian König } else if ((mb.macroblock_type & PIPE_MPEG12_MB_TYPE_INTRA) && bs->desc->concealment_motion_vectors) { 8658ea416f35de0c664ef47b71841756758f22d7faaChristian König if (bs->desc->picture_structure == PIPE_MPEG12_PICTURE_STRUCTURE_FRAME) 8669765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.macroblock_modes.bits.frame_motion_type = 2; 8679765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König else 8689765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.macroblock_modes.bits.field_motion_type = 1; 869c888fe027c338f337123de4da2de1ac73b0f7587Christian König } 870c888fe027c338f337123de4da2de1ac73b0f7587Christian König 8718ea416f35de0c664ef47b71841756758f22d7faaChristian König if (bs->desc->picture_structure == PIPE_MPEG12_PICTURE_STRUCTURE_FRAME && 8728ea416f35de0c664ef47b71841756758f22d7faaChristian König bs->desc->frame_pred_frame_dct == 0 && 8739765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.macroblock_type & (PIPE_MPEG12_MB_TYPE_INTRA | PIPE_MPEG12_MB_TYPE_PATTERN)) 8749765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.macroblock_modes.bits.dct_type = vl_vlc_get_uimsbf(&bs->vlc, 1); 875c888fe027c338f337123de4da2de1ac73b0f7587Christian König 8769765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (mb.macroblock_type & PIPE_MPEG12_MB_TYPE_QUANT) 8778ea416f35de0c664ef47b71841756758f22d7faaChristian König dct_scale = quant_scale[bs->desc->q_scale_type][vl_vlc_get_uimsbf(&bs->vlc, 5)]; 878c888fe027c338f337123de4da2de1ac73b0f7587Christian König 8798ea416f35de0c664ef47b71841756758f22d7faaChristian König if (inc > 1 && bs->desc->picture_coding_type == PIPE_MPEG12_PICTURE_CODING_TYPE_P) 8809765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König memset(mb.PMV, 0, sizeof(mb.PMV)); 881c888fe027c338f337123de4da2de1ac73b0f7587Christian König 8829765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.motion_vertical_field_select = 0; 8839765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if ((mb.macroblock_type & PIPE_MPEG12_MB_TYPE_MOTION_FORWARD) || 8848ea416f35de0c664ef47b71841756758f22d7faaChristian König (mb.macroblock_type & PIPE_MPEG12_MB_TYPE_INTRA && bs->desc->concealment_motion_vectors)) { 8858ea416f35de0c664ef47b71841756758f22d7faaChristian König if (bs->desc->picture_structure == PIPE_MPEG12_PICTURE_STRUCTURE_FRAME) 8869765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König motion_vector_frame(bs, 0, &mb); 887c888fe027c338f337123de4da2de1ac73b0f7587Christian König else 8889765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König motion_vector_field(bs, 0, &mb); 889c888fe027c338f337123de4da2de1ac73b0f7587Christian König } 890c888fe027c338f337123de4da2de1ac73b0f7587Christian König 8919765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (mb.macroblock_type & PIPE_MPEG12_MB_TYPE_MOTION_BACKWARD) { 8928ea416f35de0c664ef47b71841756758f22d7faaChristian König if (bs->desc->picture_structure == PIPE_MPEG12_PICTURE_STRUCTURE_FRAME) 8939765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König motion_vector_frame(bs, 1, &mb); 8949765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König else 8959765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König motion_vector_field(bs, 1, &mb); 896235de23e57bd6dac6a2fcdd0807838eef72f6173Christian König } 897c888fe027c338f337123de4da2de1ac73b0f7587Christian König 8988ea416f35de0c664ef47b71841756758f22d7faaChristian König if (mb.macroblock_type & PIPE_MPEG12_MB_TYPE_INTRA && bs->desc->concealment_motion_vectors) { 8999765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König unsigned extra = vl_vlc_get_uimsbf(&bs->vlc, 1); 9009765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.PMV[1][0][0] = mb.PMV[0][0][0]; 9019765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.PMV[1][0][1] = mb.PMV[0][0][1]; 9029765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König assert(extra); 9039765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König } else if (mb.macroblock_type & PIPE_MPEG12_MB_TYPE_INTRA || 9049765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König !(mb.macroblock_type & (PIPE_MPEG12_MB_TYPE_MOTION_FORWARD | 9059765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König PIPE_MPEG12_MB_TYPE_MOTION_BACKWARD))) { 9069765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König memset(mb.PMV, 0, sizeof(mb.PMV)); 907c888fe027c338f337123de4da2de1ac73b0f7587Christian König } 9086c731191c08561ea247cb2fcfacdf08f6b842363Christian König 9099765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if ((mb.macroblock_type & PIPE_MPEG12_MB_TYPE_MOTION_FORWARD && 9109765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.macroblock_modes.bits.frame_motion_type == 2) || 9119765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König (mb.macroblock_modes.bits.frame_motion_type == 3)) { 9129765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.PMV[1][0][0] = mb.PMV[0][0][0]; 9139765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.PMV[1][0][1] = mb.PMV[0][0][1]; 914c888fe027c338f337123de4da2de1ac73b0f7587Christian König } 9159765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König 9169765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (mb.macroblock_type & PIPE_MPEG12_MB_TYPE_MOTION_BACKWARD && 9179765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.macroblock_modes.bits.frame_motion_type == 2) { 9189765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.PMV[1][1][0] = mb.PMV[0][1][0]; 9199765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.PMV[1][1][1] = mb.PMV[0][1][1]; 920235de23e57bd6dac6a2fcdd0807838eef72f6173Christian König } 9219765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König 9229765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (inc > 1 || !(mb.macroblock_type & PIPE_MPEG12_MB_TYPE_INTRA)) 9239765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König reset_predictor(bs); 9249765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König 9259765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (mb.macroblock_type & (PIPE_MPEG12_MB_TYPE_INTRA | PIPE_MPEG12_MB_TYPE_PATTERN)) { 9269765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König memset(dct_blocks, 0, sizeof(dct_blocks)); 9279765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König decode_dct(bs, &mb, dct_scale); 9289765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König } else 9299765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.coded_block_pattern = 0; 9309765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König 931d4bbdbd03893e900d8bcf0b46e8307a877d1a3aeChristian König vl_vlc_fillbits(&bs->vlc); 932d4bbdbd03893e900d8bcf0b46e8307a877d1a3aeChristian König } while (vl_vlc_bits_left(&bs->vlc) && vl_vlc_peekbits(&bs->vlc, 23)); 9339765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König 9349765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König mb.num_skipped_macroblocks = 0; 9358ea416f35de0c664ef47b71841756758f22d7faaChristian König bs->decoder->decode_macroblock(bs->decoder, target, &bs->desc->base, &mb.base, 1); 936c888fe027c338f337123de4da2de1ac73b0f7587Christian König} 937c888fe027c338f337123de4da2de1ac73b0f7587Christian König 938c888fe027c338f337123de4da2de1ac73b0f7587Christian Königvoid 9399765dede7556f7ccfef1d90bab14a2bfa03384e5Christian Königvl_mpg12_bs_init(struct vl_mpg12_bs *bs, struct pipe_video_decoder *decoder) 940c888fe027c338f337123de4da2de1ac73b0f7587Christian König{ 9419765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König static bool tables_initialized = false; 9429765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König 943c888fe027c338f337123de4da2de1ac73b0f7587Christian König assert(bs); 944c888fe027c338f337123de4da2de1ac73b0f7587Christian König 945c888fe027c338f337123de4da2de1ac73b0f7587Christian König memset(bs, 0, sizeof(struct vl_mpg12_bs)); 946c888fe027c338f337123de4da2de1ac73b0f7587Christian König 9479765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König bs->decoder = decoder; 9489765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König 9499765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König if (!tables_initialized) { 9509765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König init_tables(); 9519765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König tables_initialized = true; 9529765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König } 953c888fe027c338f337123de4da2de1ac73b0f7587Christian König} 954c888fe027c338f337123de4da2de1ac73b0f7587Christian König 955c888fe027c338f337123de4da2de1ac73b0f7587Christian Königvoid 9568ea416f35de0c664ef47b71841756758f22d7faaChristian Königvl_mpg12_bs_decode(struct vl_mpg12_bs *bs, 9578ea416f35de0c664ef47b71841756758f22d7faaChristian König struct pipe_video_buffer *target, 9588ea416f35de0c664ef47b71841756758f22d7faaChristian König struct pipe_mpeg12_picture_desc *picture, 9598ea416f35de0c664ef47b71841756758f22d7faaChristian König unsigned num_buffers, 9608ea416f35de0c664ef47b71841756758f22d7faaChristian König const void * const *buffers, 9618ea416f35de0c664ef47b71841756758f22d7faaChristian König const unsigned *sizes) 962c888fe027c338f337123de4da2de1ac73b0f7587Christian König{ 963c888fe027c338f337123de4da2de1ac73b0f7587Christian König assert(bs); 964c888fe027c338f337123de4da2de1ac73b0f7587Christian König 9658ea416f35de0c664ef47b71841756758f22d7faaChristian König bs->desc = picture; 9668ea416f35de0c664ef47b71841756758f22d7faaChristian König bs->intra_dct_tbl = picture->intra_vlc_format ? tbl_B15 : tbl_B14_AC; 9678ea416f35de0c664ef47b71841756758f22d7faaChristian König 9687ac114f94a8fac5fa7cc0e99bf6a3c03ec194650Christian König vl_vlc_init(&bs->vlc, num_buffers, buffers, sizes); 969efa93ae449b6dc8437ee7240a8ea050a0d1699e0Maarten Lankhorst while (vl_vlc_bits_left(&bs->vlc) > 32) { 970efa93ae449b6dc8437ee7240a8ea050a0d1699e0Maarten Lankhorst uint32_t code = vl_vlc_peekbits(&bs->vlc, 32); 9719765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König 972efa93ae449b6dc8437ee7240a8ea050a0d1699e0Maarten Lankhorst if (code >= 0x101 && code <= 0x1AF) { 973efa93ae449b6dc8437ee7240a8ea050a0d1699e0Maarten Lankhorst vl_vlc_eatbits(&bs->vlc, 24); 9748ea416f35de0c664ef47b71841756758f22d7faaChristian König decode_slice(bs, target); 9759765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König 976efa93ae449b6dc8437ee7240a8ea050a0d1699e0Maarten Lankhorst /* align to a byte again */ 977efa93ae449b6dc8437ee7240a8ea050a0d1699e0Maarten Lankhorst vl_vlc_eatbits(&bs->vlc, vl_vlc_valid_bits(&bs->vlc) & 7); 9789765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König 9799765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König } else { 980efa93ae449b6dc8437ee7240a8ea050a0d1699e0Maarten Lankhorst vl_vlc_eatbits(&bs->vlc, 8); 9819765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König } 982efa93ae449b6dc8437ee7240a8ea050a0d1699e0Maarten Lankhorst 983efa93ae449b6dc8437ee7240a8ea050a0d1699e0Maarten Lankhorst vl_vlc_fillbits(&bs->vlc); 9849765dede7556f7ccfef1d90bab14a2bfa03384e5Christian König } 985c888fe027c338f337123de4da2de1ac73b0f7587Christian König} 986