Home | History | Annotate | Download | only in common
      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 
     12 #include "vp9/common/vp9_blockd.h"
     13 #include "vp9/common/vp9_common_data.h"
     14 
     15 // Log 2 conversion lookup tables for block width and height
     16 const int b_width_log2_lookup[BLOCK_SIZES] =
     17   {0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4};
     18 const int b_height_log2_lookup[BLOCK_SIZES] =
     19   {0, 1, 0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4};
     20 const int num_4x4_blocks_wide_lookup[BLOCK_SIZES] =
     21   {1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8, 16, 16};
     22 const int num_4x4_blocks_high_lookup[BLOCK_SIZES] =
     23   {1, 2, 1, 2, 4, 2, 4, 8, 4, 8, 16, 8, 16};
     24 // Log 2 conversion lookup tables for modeinfo width and height
     25 const int mi_width_log2_lookup[BLOCK_SIZES] =
     26   {0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3};
     27 const int num_8x8_blocks_wide_lookup[BLOCK_SIZES] =
     28   {1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 8, 8};
     29 const int mi_height_log2_lookup[BLOCK_SIZES] =
     30   {0, 0, 0, 0, 1, 0, 1, 2, 1, 2, 3, 2, 3};
     31 const int num_8x8_blocks_high_lookup[BLOCK_SIZES] =
     32   {1, 1, 1, 1, 2, 1, 2, 4, 2, 4, 8, 4, 8};
     33 
     34 // MIN(3, MIN(b_width_log2(bsize), b_height_log2(bsize)))
     35 const int size_group_lookup[BLOCK_SIZES] =
     36   {0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3};
     37 
     38 const int num_pels_log2_lookup[BLOCK_SIZES] =
     39   {4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 11, 11, 12};
     40 
     41 
     42 const PARTITION_TYPE partition_lookup[][BLOCK_SIZES] = {
     43   {  // 4X4
     44     // 4X4, 4X8,8X4,8X8,8X16,16X8,16X16,16X32,32X16,32X32,32X64,64X32,64X64
     45     PARTITION_NONE, PARTITION_INVALID, PARTITION_INVALID,
     46     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
     47     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
     48     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
     49     PARTITION_INVALID
     50   }, {  // 8X8
     51     // 4X4, 4X8,8X4,8X8,8X16,16X8,16X16,16X32,32X16,32X32,32X64,64X32,64X64
     52     PARTITION_SPLIT, PARTITION_VERT, PARTITION_HORZ, PARTITION_NONE,
     53     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
     54     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
     55     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID
     56   }, {  // 16X16
     57     // 4X4, 4X8,8X4,8X8,8X16,16X8,16X16,16X32,32X16,32X32,32X64,64X32,64X64
     58     PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT,
     59     PARTITION_VERT, PARTITION_HORZ, PARTITION_NONE, PARTITION_INVALID,
     60     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
     61     PARTITION_INVALID, PARTITION_INVALID
     62   }, {  // 32X32
     63     // 4X4, 4X8,8X4,8X8,8X16,16X8,16X16,16X32,32X16,32X32,32X64,64X32,64X64
     64     PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT,
     65     PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_VERT,
     66     PARTITION_HORZ, PARTITION_NONE, PARTITION_INVALID,
     67     PARTITION_INVALID, PARTITION_INVALID
     68   }, {  // 64X64
     69     // 4X4, 4X8,8X4,8X8,8X16,16X8,16X16,16X32,32X16,32X32,32X64,64X32,64X64
     70     PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT,
     71     PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_SPLIT,
     72     PARTITION_SPLIT, PARTITION_SPLIT, PARTITION_VERT, PARTITION_HORZ,
     73     PARTITION_NONE
     74   }
     75 };
     76 
     77 const BLOCK_SIZE subsize_lookup[PARTITION_TYPES][BLOCK_SIZES] = {
     78   {     // PARTITION_NONE
     79     BLOCK_4X4,   BLOCK_4X8,   BLOCK_8X4,
     80     BLOCK_8X8,   BLOCK_8X16,  BLOCK_16X8,
     81     BLOCK_16X16, BLOCK_16X32, BLOCK_32X16,
     82     BLOCK_32X32, BLOCK_32X64, BLOCK_64X32,
     83     BLOCK_64X64,
     84   }, {  // PARTITION_HORZ
     85     BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
     86     BLOCK_8X4,     BLOCK_INVALID, BLOCK_INVALID,
     87     BLOCK_16X8,    BLOCK_INVALID, BLOCK_INVALID,
     88     BLOCK_32X16,   BLOCK_INVALID, BLOCK_INVALID,
     89     BLOCK_64X32,
     90   }, {  // PARTITION_VERT
     91     BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
     92     BLOCK_4X8,     BLOCK_INVALID, BLOCK_INVALID,
     93     BLOCK_8X16,    BLOCK_INVALID, BLOCK_INVALID,
     94     BLOCK_16X32,   BLOCK_INVALID, BLOCK_INVALID,
     95     BLOCK_32X64,
     96   }, {  // PARTITION_SPLIT
     97     BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
     98     BLOCK_4X4,     BLOCK_INVALID, BLOCK_INVALID,
     99     BLOCK_8X8,     BLOCK_INVALID, BLOCK_INVALID,
    100     BLOCK_16X16,   BLOCK_INVALID, BLOCK_INVALID,
    101     BLOCK_32X32,
    102   }
    103 };
    104 
    105 const TX_SIZE max_txsize_lookup[BLOCK_SIZES] = {
    106   TX_4X4,   TX_4X4,   TX_4X4,
    107   TX_8X8,   TX_8X8,   TX_8X8,
    108   TX_16X16, TX_16X16, TX_16X16,
    109   TX_32X32, TX_32X32, TX_32X32, TX_32X32
    110 };
    111 const TX_SIZE max_uv_txsize_lookup[BLOCK_SIZES] = {
    112   TX_4X4,   TX_4X4,   TX_4X4,
    113   TX_4X4,   TX_4X4,   TX_4X4,
    114   TX_8X8,   TX_8X8,   TX_8X8,
    115   TX_16X16, TX_16X16, TX_16X16, TX_32X32
    116 };
    117 
    118 const TX_SIZE tx_mode_to_biggest_tx_size[TX_MODES] = {
    119   TX_4X4,  // ONLY_4X4
    120   TX_8X8,  // ALLOW_8X8
    121   TX_16X16,  // ALLOW_16X16
    122   TX_32X32,  // ALLOW_32X32
    123   TX_32X32,  // TX_MODE_SELECT
    124 };
    125 
    126 
    127 
    128 const BLOCK_SIZE ss_size_lookup[BLOCK_SIZES][2][2] = {
    129 //  ss_x == 0    ss_x == 0        ss_x == 1      ss_x == 1
    130 //  ss_y == 0    ss_y == 1        ss_y == 0      ss_y == 1
    131   {{BLOCK_4X4,   BLOCK_INVALID}, {BLOCK_INVALID, BLOCK_INVALID}},
    132   {{BLOCK_4X8,   BLOCK_4X4},     {BLOCK_INVALID, BLOCK_INVALID}},
    133   {{BLOCK_8X4,   BLOCK_INVALID}, {BLOCK_4X4,     BLOCK_INVALID}},
    134   {{BLOCK_8X8,   BLOCK_8X4},     {BLOCK_4X8,     BLOCK_4X4}},
    135   {{BLOCK_8X16,  BLOCK_8X8},     {BLOCK_INVALID, BLOCK_4X8}},
    136   {{BLOCK_16X8,  BLOCK_INVALID}, {BLOCK_8X8,     BLOCK_8X4}},
    137   {{BLOCK_16X16, BLOCK_16X8},    {BLOCK_8X16,    BLOCK_8X8}},
    138   {{BLOCK_16X32, BLOCK_16X16},   {BLOCK_INVALID, BLOCK_8X16}},
    139   {{BLOCK_32X16, BLOCK_INVALID}, {BLOCK_16X16,   BLOCK_16X8}},
    140   {{BLOCK_32X32, BLOCK_32X16},   {BLOCK_16X32,   BLOCK_16X16}},
    141   {{BLOCK_32X64, BLOCK_32X32},   {BLOCK_INVALID, BLOCK_16X32}},
    142   {{BLOCK_64X32, BLOCK_INVALID}, {BLOCK_32X32,   BLOCK_32X16}},
    143   {{BLOCK_64X64, BLOCK_64X32},   {BLOCK_32X64,   BLOCK_32X32}},
    144 };
    145 
    146 
    147