vp9_common_data.c 6.53 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/*
 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#include "vp9/common/vp9_common_data.h"
12
#include "vpx_dsp/vpx_dsp_common.h"
13 14

// Log 2 conversion lookup tables for block width and height
15
const uint8_t b_width_log2_lookup[BLOCK_SIZES] =
16
  {0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4};
17
const uint8_t b_height_log2_lookup[BLOCK_SIZES] =
18
  {0, 1, 0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4};
19
const uint8_t num_4x4_blocks_wide_lookup[BLOCK_SIZES] =
Jim Bankoski's avatar
Jim Bankoski committed
20
  {1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8, 16, 16};
21
const uint8_t num_4x4_blocks_high_lookup[BLOCK_SIZES] =
Jim Bankoski's avatar
Jim Bankoski committed
22
  {1, 2, 1, 2, 4, 2, 4, 8, 4, 8, 16, 8, 16};
Jim Bankoski's avatar
Jim Bankoski committed
23
// Log 2 conversion lookup tables for modeinfo width and height
24
const uint8_t mi_width_log2_lookup[BLOCK_SIZES] =
Jim Bankoski's avatar
Jim Bankoski committed
25
  {0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3};
26
const uint8_t num_8x8_blocks_wide_lookup[BLOCK_SIZES] =
Jim Bankoski's avatar
Jim Bankoski committed
27
  {1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 8, 8};
28
const uint8_t num_8x8_blocks_high_lookup[BLOCK_SIZES] =
Jim Bankoski's avatar
Jim Bankoski committed
29 30
  {1, 1, 1, 1, 2, 1, 2, 4, 2, 4, 8, 4, 8};

31
// VPXMIN(3, VPXMIN(b_width_log2(bsize), b_height_log2(bsize)))
32
const uint8_t size_group_lookup[BLOCK_SIZES] =
33 34
  {0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3};

35
const uint8_t num_pels_log2_lookup[BLOCK_SIZES] =
36 37
  {4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 11, 11, 12};

38
const PARTITION_TYPE partition_lookup[][BLOCK_SIZES] = {
Jim Bankoski's avatar
Jim Bankoski committed
39 40 41 42 43 44 45 46
  {  // 4X4
    // 4X4, 4X8,8X4,8X8,8X16,16X8,16X16,16X32,32X16,32X32,32X64,64X32,64X64
    PARTITION_NONE, PARTITION_INVALID, PARTITION_INVALID,
    PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
    PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
    PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
    PARTITION_INVALID
  }, {  // 8X8
Jim Bankoski's avatar
Jim Bankoski committed
47
    // 4X4, 4X8,8X4,8X8,8X16,16X8,16X16,16X32,32X16,32X32,32X64,64X32,64X64
Jim Bankoski's avatar
Jim Bankoski committed
48 49 50 51 52
    PARTITION_SPLIT, PARTITION_VERT, PARTITION_HORZ, PARTITION_NONE,
    PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
    PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
    PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID
  }, {  // 16X16
Jim Bankoski's avatar
Jim Bankoski committed
53
    // 4X4, 4X8,8X4,8X8,8X16,16X8,16X16,16X32,32X16,32X32,32X64,64X32,64X64
Jim Bankoski's avatar
Jim Bankoski committed
54 55 56 57 58
    PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT,
    PARTITION_VERT, PARTITION_HORZ, PARTITION_NONE, PARTITION_INVALID,
    PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
    PARTITION_INVALID, PARTITION_INVALID
  }, {  // 32X32
Jim Bankoski's avatar
Jim Bankoski committed
59
    // 4X4, 4X8,8X4,8X8,8X16,16X8,16X16,16X32,32X16,32X32,32X64,64X32,64X64
Jim Bankoski's avatar
Jim Bankoski committed
60 61 62 63 64
    PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT,
    PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_VERT,
    PARTITION_HORZ, PARTITION_NONE, PARTITION_INVALID,
    PARTITION_INVALID, PARTITION_INVALID
  }, {  // 64X64
Jim Bankoski's avatar
Jim Bankoski committed
65
    // 4X4, 4X8,8X4,8X8,8X16,16X8,16X16,16X32,32X16,32X32,32X64,64X32,64X64
Jim Bankoski's avatar
Jim Bankoski committed
66 67 68 69 70 71
    PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT,
    PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT,
    PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_VERT, PARTITION_HORZ,
    PARTITION_NONE
  }
};
72

73
const BLOCK_SIZE subsize_lookup[PARTITION_TYPES][BLOCK_SIZES] = {
74
  {     // PARTITION_NONE
Dmitry Kovalev's avatar
Dmitry Kovalev committed
75 76
    BLOCK_4X4,   BLOCK_4X8,   BLOCK_8X4,
    BLOCK_8X8,   BLOCK_8X16,  BLOCK_16X8,
77 78 79
    BLOCK_16X16, BLOCK_16X32, BLOCK_32X16,
    BLOCK_32X32, BLOCK_32X64, BLOCK_64X32,
    BLOCK_64X64,
80
  }, {  // PARTITION_HORZ
Dmitry Kovalev's avatar
Dmitry Kovalev committed
81 82 83 84
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_8X4,     BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_16X8,    BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_32X16,   BLOCK_INVALID, BLOCK_INVALID,
85
    BLOCK_64X32,
86
  }, {  // PARTITION_VERT
Dmitry Kovalev's avatar
Dmitry Kovalev committed
87 88 89 90
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_4X8,     BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_8X16,    BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_16X32,   BLOCK_INVALID, BLOCK_INVALID,
91
    BLOCK_32X64,
92
  }, {  // PARTITION_SPLIT
Dmitry Kovalev's avatar
Dmitry Kovalev committed
93 94 95 96
    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_4X4,     BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_8X8,     BLOCK_INVALID, BLOCK_INVALID,
    BLOCK_16X16,   BLOCK_INVALID, BLOCK_INVALID,
97
    BLOCK_32X32,
98 99 100
  }
};

101
const TX_SIZE max_txsize_lookup[BLOCK_SIZES] = {
Dmitry Kovalev's avatar
Dmitry Kovalev committed
102 103
  TX_4X4,   TX_4X4,   TX_4X4,
  TX_8X8,   TX_8X8,   TX_8X8,
104 105 106 107
  TX_16X16, TX_16X16, TX_16X16,
  TX_32X32, TX_32X32, TX_32X32, TX_32X32
};

108 109 110 111 112 113 114
const BLOCK_SIZE txsize_to_bsize[TX_SIZES] = {
    BLOCK_4X4,  // TX_4X4
    BLOCK_8X8,  // TX_8X8
    BLOCK_16X16,  // TX_16X16
    BLOCK_32X32,  // TX_32X32
};

Yaowu Xu's avatar
Yaowu Xu committed
115 116 117 118 119 120 121 122
const TX_SIZE tx_mode_to_biggest_tx_size[TX_MODES] = {
  TX_4X4,  // ONLY_4X4
  TX_8X8,  // ALLOW_8X8
  TX_16X16,  // ALLOW_16X16
  TX_32X32,  // ALLOW_32X32
  TX_32X32,  // TX_MODE_SELECT
};

123
const BLOCK_SIZE ss_size_lookup[BLOCK_SIZES][2][2] = {
Dmitry Kovalev's avatar
Dmitry Kovalev committed
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
//  ss_x == 0    ss_x == 0        ss_x == 1      ss_x == 1
//  ss_y == 0    ss_y == 1        ss_y == 0      ss_y == 1
  {{BLOCK_4X4,   BLOCK_INVALID}, {BLOCK_INVALID, BLOCK_INVALID}},
  {{BLOCK_4X8,   BLOCK_4X4},     {BLOCK_INVALID, BLOCK_INVALID}},
  {{BLOCK_8X4,   BLOCK_INVALID}, {BLOCK_4X4,     BLOCK_INVALID}},
  {{BLOCK_8X8,   BLOCK_8X4},     {BLOCK_4X8,     BLOCK_4X4}},
  {{BLOCK_8X16,  BLOCK_8X8},     {BLOCK_INVALID, BLOCK_4X8}},
  {{BLOCK_16X8,  BLOCK_INVALID}, {BLOCK_8X8,     BLOCK_8X4}},
  {{BLOCK_16X16, BLOCK_16X8},    {BLOCK_8X16,    BLOCK_8X8}},
  {{BLOCK_16X32, BLOCK_16X16},   {BLOCK_INVALID, BLOCK_8X16}},
  {{BLOCK_32X16, BLOCK_INVALID}, {BLOCK_16X16,   BLOCK_16X8}},
  {{BLOCK_32X32, BLOCK_32X16},   {BLOCK_16X32,   BLOCK_16X16}},
  {{BLOCK_32X64, BLOCK_32X32},   {BLOCK_INVALID, BLOCK_16X32}},
  {{BLOCK_64X32, BLOCK_INVALID}, {BLOCK_32X32,   BLOCK_32X16}},
  {{BLOCK_64X64, BLOCK_64X32},   {BLOCK_32X64,   BLOCK_32X32}},
139
};
Dmitry Kovalev's avatar
Dmitry Kovalev committed
140

141
// Generates 4 bit field in which each bit set to 1 represents
142 143
// a blocksize partition  1111 means we split 64x64, 32x32, 16x16
// and 8x8.  1000 means we just split the 64x64 to 32x32
144 145 146 147
const struct {
  PARTITION_CONTEXT above;
  PARTITION_CONTEXT left;
} partition_context_lookup[BLOCK_SIZES]= {
148 149 150 151 152 153 154 155 156 157 158 159 160
  {15, 15},  // 4X4   - {0b1111, 0b1111}
  {15, 14},  // 4X8   - {0b1111, 0b1110}
  {14, 15},  // 8X4   - {0b1110, 0b1111}
  {14, 14},  // 8X8   - {0b1110, 0b1110}
  {14, 12},  // 8X16  - {0b1110, 0b1100}
  {12, 14},  // 16X8  - {0b1100, 0b1110}
  {12, 12},  // 16X16 - {0b1100, 0b1100}
  {12, 8 },  // 16X32 - {0b1100, 0b1000}
  {8,  12},  // 32X16 - {0b1000, 0b1100}
  {8,  8 },  // 32X32 - {0b1000, 0b1000}
  {8,  0 },  // 32X64 - {0b1000, 0b0000}
  {0,  8 },  // 64X32 - {0b0000, 0b1000}
  {0,  0 },  // 64X64 - {0b0000, 0b0000}
161
};