• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #include "vp9/common/vp9_common_data.h"
12 
13 // Log 2 conversion lookup tables for block width and height
14 const uint8_t b_width_log2_lookup[BLOCK_SIZES] =
15   {0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4};
16 const uint8_t b_height_log2_lookup[BLOCK_SIZES] =
17   {0, 1, 0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4};
18 const uint8_t num_4x4_blocks_wide_lookup[BLOCK_SIZES] =
19   {1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8, 16, 16};
20 const uint8_t num_4x4_blocks_high_lookup[BLOCK_SIZES] =
21   {1, 2, 1, 2, 4, 2, 4, 8, 4, 8, 16, 8, 16};
22 // Log 2 conversion lookup tables for modeinfo width and height
23 const uint8_t mi_width_log2_lookup[BLOCK_SIZES] =
24   {0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3};
25 const uint8_t num_8x8_blocks_wide_lookup[BLOCK_SIZES] =
26   {1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 8, 8};
27 const uint8_t num_8x8_blocks_high_lookup[BLOCK_SIZES] =
28   {1, 1, 1, 1, 2, 1, 2, 4, 2, 4, 8, 4, 8};
29 
30 // MIN(3, MIN(b_width_log2(bsize), b_height_log2(bsize)))
31 const uint8_t size_group_lookup[BLOCK_SIZES] =
32   {0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3};
33 
34 const uint8_t num_pels_log2_lookup[BLOCK_SIZES] =
35   {4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 11, 11, 12};
36 
37 const PARTITION_TYPE partition_lookup[][BLOCK_SIZES] = {
38   {  // 4X4
39     // 4X4, 4X8,8X4,8X8,8X16,16X8,16X16,16X32,32X16,32X32,32X64,64X32,64X64
40     PARTITION_NONE, PARTITION_INVALID, PARTITION_INVALID,
41     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
42     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
43     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
44     PARTITION_INVALID
45   }, {  // 8X8
46     // 4X4, 4X8,8X4,8X8,8X16,16X8,16X16,16X32,32X16,32X32,32X64,64X32,64X64
47     PARTITION_SPLIT, PARTITION_VERT, PARTITION_HORZ, PARTITION_NONE,
48     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
49     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
50     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID
51   }, {  // 16X16
52     // 4X4, 4X8,8X4,8X8,8X16,16X8,16X16,16X32,32X16,32X32,32X64,64X32,64X64
53     PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT,
54     PARTITION_VERT, PARTITION_HORZ, PARTITION_NONE, PARTITION_INVALID,
55     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
56     PARTITION_INVALID, PARTITION_INVALID
57   }, {  // 32X32
58     // 4X4, 4X8,8X4,8X8,8X16,16X8,16X16,16X32,32X16,32X32,32X64,64X32,64X64
59     PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT,
60     PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_VERT,
61     PARTITION_HORZ, PARTITION_NONE, PARTITION_INVALID,
62     PARTITION_INVALID, PARTITION_INVALID
63   }, {  // 64X64
64     // 4X4, 4X8,8X4,8X8,8X16,16X8,16X16,16X32,32X16,32X32,32X64,64X32,64X64
65     PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT,
66     PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT,
67     PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_VERT, PARTITION_HORZ,
68     PARTITION_NONE
69   }
70 };
71 
72 const BLOCK_SIZE subsize_lookup[PARTITION_TYPES][BLOCK_SIZES] = {
73   {     // PARTITION_NONE
74     BLOCK_4X4,   BLOCK_4X8,   BLOCK_8X4,
75     BLOCK_8X8,   BLOCK_8X16,  BLOCK_16X8,
76     BLOCK_16X16, BLOCK_16X32, BLOCK_32X16,
77     BLOCK_32X32, BLOCK_32X64, BLOCK_64X32,
78     BLOCK_64X64,
79   }, {  // PARTITION_HORZ
80     BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
81     BLOCK_8X4,     BLOCK_INVALID, BLOCK_INVALID,
82     BLOCK_16X8,    BLOCK_INVALID, BLOCK_INVALID,
83     BLOCK_32X16,   BLOCK_INVALID, BLOCK_INVALID,
84     BLOCK_64X32,
85   }, {  // PARTITION_VERT
86     BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
87     BLOCK_4X8,     BLOCK_INVALID, BLOCK_INVALID,
88     BLOCK_8X16,    BLOCK_INVALID, BLOCK_INVALID,
89     BLOCK_16X32,   BLOCK_INVALID, BLOCK_INVALID,
90     BLOCK_32X64,
91   }, {  // PARTITION_SPLIT
92     BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
93     BLOCK_4X4,     BLOCK_INVALID, BLOCK_INVALID,
94     BLOCK_8X8,     BLOCK_INVALID, BLOCK_INVALID,
95     BLOCK_16X16,   BLOCK_INVALID, BLOCK_INVALID,
96     BLOCK_32X32,
97   }
98 };
99 
100 const TX_SIZE max_txsize_lookup[BLOCK_SIZES] = {
101   TX_4X4,   TX_4X4,   TX_4X4,
102   TX_8X8,   TX_8X8,   TX_8X8,
103   TX_16X16, TX_16X16, TX_16X16,
104   TX_32X32, TX_32X32, TX_32X32, TX_32X32
105 };
106 
107 const BLOCK_SIZE txsize_to_bsize[TX_SIZES] = {
108     BLOCK_4X4,  // TX_4X4
109     BLOCK_8X8,  // TX_8X8
110     BLOCK_16X16,  // TX_16X16
111     BLOCK_32X32,  // TX_32X32
112 };
113 
114 const TX_SIZE tx_mode_to_biggest_tx_size[TX_MODES] = {
115   TX_4X4,  // ONLY_4X4
116   TX_8X8,  // ALLOW_8X8
117   TX_16X16,  // ALLOW_16X16
118   TX_32X32,  // ALLOW_32X32
119   TX_32X32,  // TX_MODE_SELECT
120 };
121 
122 const BLOCK_SIZE ss_size_lookup[BLOCK_SIZES][2][2] = {
123 //  ss_x == 0    ss_x == 0        ss_x == 1      ss_x == 1
124 //  ss_y == 0    ss_y == 1        ss_y == 0      ss_y == 1
125   {{BLOCK_4X4,   BLOCK_INVALID}, {BLOCK_INVALID, BLOCK_INVALID}},
126   {{BLOCK_4X8,   BLOCK_4X4},     {BLOCK_INVALID, BLOCK_INVALID}},
127   {{BLOCK_8X4,   BLOCK_INVALID}, {BLOCK_4X4,     BLOCK_INVALID}},
128   {{BLOCK_8X8,   BLOCK_8X4},     {BLOCK_4X8,     BLOCK_4X4}},
129   {{BLOCK_8X16,  BLOCK_8X8},     {BLOCK_INVALID, BLOCK_4X8}},
130   {{BLOCK_16X8,  BLOCK_INVALID}, {BLOCK_8X8,     BLOCK_8X4}},
131   {{BLOCK_16X16, BLOCK_16X8},    {BLOCK_8X16,    BLOCK_8X8}},
132   {{BLOCK_16X32, BLOCK_16X16},   {BLOCK_INVALID, BLOCK_8X16}},
133   {{BLOCK_32X16, BLOCK_INVALID}, {BLOCK_16X16,   BLOCK_16X8}},
134   {{BLOCK_32X32, BLOCK_32X16},   {BLOCK_16X32,   BLOCK_16X16}},
135   {{BLOCK_32X64, BLOCK_32X32},   {BLOCK_INVALID, BLOCK_16X32}},
136   {{BLOCK_64X32, BLOCK_INVALID}, {BLOCK_32X32,   BLOCK_32X16}},
137   {{BLOCK_64X64, BLOCK_64X32},   {BLOCK_32X64,   BLOCK_32X32}},
138 };
139 
140 // Generates 4 bit field in which each bit set to 1 represents
141 // a blocksize partition  1111 means we split 64x64, 32x32, 16x16
142 // and 8x8.  1000 means we just split the 64x64 to 32x32
143 const struct {
144   PARTITION_CONTEXT above;
145   PARTITION_CONTEXT left;
146 } partition_context_lookup[BLOCK_SIZES]= {
147   {15, 15},  // 4X4   - {0b1111, 0b1111}
148   {15, 14},  // 4X8   - {0b1111, 0b1110}
149   {14, 15},  // 8X4   - {0b1110, 0b1111}
150   {14, 14},  // 8X8   - {0b1110, 0b1110}
151   {14, 12},  // 8X16  - {0b1110, 0b1100}
152   {12, 14},  // 16X8  - {0b1100, 0b1110}
153   {12, 12},  // 16X16 - {0b1100, 0b1100}
154   {12, 8 },  // 16X32 - {0b1100, 0b1000}
155   {8,  12},  // 32X16 - {0b1000, 0b1100}
156   {8,  8 },  // 32X32 - {0b1000, 0b1000}
157   {8,  0 },  // 32X64 - {0b1000, 0b0000}
158   {0,  8 },  // 64X32 - {0b0000, 0b1000}
159   {0,  0 },  // 64X64 - {0b0000, 0b0000}
160 };
161