1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libvpx/vp8/common/entropymode.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,171 @@ 1.4 +/* 1.5 + * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license 1.8 + * that can be found in the LICENSE file in the root of the source 1.9 + * tree. An additional intellectual property rights grant can be found 1.10 + * in the file PATENTS. All contributing project authors may 1.11 + * be found in the AUTHORS file in the root of the source tree. 1.12 + */ 1.13 + 1.14 +#define USE_PREBUILT_TABLES 1.15 + 1.16 +#include "entropymode.h" 1.17 +#include "entropy.h" 1.18 +#include "vpx_mem/vpx_mem.h" 1.19 + 1.20 +#include "vp8_entropymodedata.h" 1.21 + 1.22 +int vp8_mv_cont(const int_mv *l, const int_mv *a) 1.23 +{ 1.24 + int lez = (l->as_int == 0); 1.25 + int aez = (a->as_int == 0); 1.26 + int lea = (l->as_int == a->as_int); 1.27 + 1.28 + if (lea && lez) 1.29 + return SUBMVREF_LEFT_ABOVE_ZED; 1.30 + 1.31 + if (lea) 1.32 + return SUBMVREF_LEFT_ABOVE_SAME; 1.33 + 1.34 + if (aez) 1.35 + return SUBMVREF_ABOVE_ZED; 1.36 + 1.37 + if (lez) 1.38 + return SUBMVREF_LEFT_ZED; 1.39 + 1.40 + return SUBMVREF_NORMAL; 1.41 +} 1.42 + 1.43 +static const vp8_prob sub_mv_ref_prob [VP8_SUBMVREFS-1] = { 180, 162, 25}; 1.44 + 1.45 +const vp8_prob vp8_sub_mv_ref_prob2 [SUBMVREF_COUNT][VP8_SUBMVREFS-1] = 1.46 +{ 1.47 + { 147, 136, 18 }, 1.48 + { 106, 145, 1 }, 1.49 + { 179, 121, 1 }, 1.50 + { 223, 1 , 34 }, 1.51 + { 208, 1 , 1 } 1.52 +}; 1.53 + 1.54 + 1.55 + 1.56 +const vp8_mbsplit vp8_mbsplits [VP8_NUMMBSPLITS] = 1.57 +{ 1.58 + { 1.59 + 0, 0, 0, 0, 1.60 + 0, 0, 0, 0, 1.61 + 1, 1, 1, 1, 1.62 + 1, 1, 1, 1, 1.63 + }, 1.64 + { 1.65 + 0, 0, 1, 1, 1.66 + 0, 0, 1, 1, 1.67 + 0, 0, 1, 1, 1.68 + 0, 0, 1, 1, 1.69 + }, 1.70 + { 1.71 + 0, 0, 1, 1, 1.72 + 0, 0, 1, 1, 1.73 + 2, 2, 3, 3, 1.74 + 2, 2, 3, 3, 1.75 + }, 1.76 + { 1.77 + 0, 1, 2, 3, 1.78 + 4, 5, 6, 7, 1.79 + 8, 9, 10, 11, 1.80 + 12, 13, 14, 15, 1.81 + } 1.82 +}; 1.83 + 1.84 +const int vp8_mbsplit_count [VP8_NUMMBSPLITS] = { 2, 2, 4, 16}; 1.85 + 1.86 +const vp8_prob vp8_mbsplit_probs [VP8_NUMMBSPLITS-1] = { 110, 111, 150}; 1.87 + 1.88 + 1.89 +/* Array indices are identical to previously-existing INTRAMODECONTEXTNODES. */ 1.90 + 1.91 +const vp8_tree_index vp8_bmode_tree[18] = /* INTRAMODECONTEXTNODE value */ 1.92 +{ 1.93 + -B_DC_PRED, 2, /* 0 = DC_NODE */ 1.94 + -B_TM_PRED, 4, /* 1 = TM_NODE */ 1.95 + -B_VE_PRED, 6, /* 2 = VE_NODE */ 1.96 + 8, 12, /* 3 = COM_NODE */ 1.97 + -B_HE_PRED, 10, /* 4 = HE_NODE */ 1.98 + -B_RD_PRED, -B_VR_PRED, /* 5 = RD_NODE */ 1.99 + -B_LD_PRED, 14, /* 6 = LD_NODE */ 1.100 + -B_VL_PRED, 16, /* 7 = VL_NODE */ 1.101 + -B_HD_PRED, -B_HU_PRED /* 8 = HD_NODE */ 1.102 +}; 1.103 + 1.104 +/* Again, these trees use the same probability indices as their 1.105 + explicitly-programmed predecessors. */ 1.106 + 1.107 +const vp8_tree_index vp8_ymode_tree[8] = 1.108 +{ 1.109 + -DC_PRED, 2, 1.110 + 4, 6, 1.111 + -V_PRED, -H_PRED, 1.112 + -TM_PRED, -B_PRED 1.113 +}; 1.114 + 1.115 +const vp8_tree_index vp8_kf_ymode_tree[8] = 1.116 +{ 1.117 + -B_PRED, 2, 1.118 + 4, 6, 1.119 + -DC_PRED, -V_PRED, 1.120 + -H_PRED, -TM_PRED 1.121 +}; 1.122 + 1.123 +const vp8_tree_index vp8_uv_mode_tree[6] = 1.124 +{ 1.125 + -DC_PRED, 2, 1.126 + -V_PRED, 4, 1.127 + -H_PRED, -TM_PRED 1.128 +}; 1.129 + 1.130 +const vp8_tree_index vp8_mbsplit_tree[6] = 1.131 +{ 1.132 + -3, 2, 1.133 + -2, 4, 1.134 + -0, -1 1.135 +}; 1.136 + 1.137 +const vp8_tree_index vp8_mv_ref_tree[8] = 1.138 +{ 1.139 + -ZEROMV, 2, 1.140 + -NEARESTMV, 4, 1.141 + -NEARMV, 6, 1.142 + -NEWMV, -SPLITMV 1.143 +}; 1.144 + 1.145 +const vp8_tree_index vp8_sub_mv_ref_tree[6] = 1.146 +{ 1.147 + -LEFT4X4, 2, 1.148 + -ABOVE4X4, 4, 1.149 + -ZERO4X4, -NEW4X4 1.150 +}; 1.151 + 1.152 +const vp8_tree_index vp8_small_mvtree [14] = 1.153 +{ 1.154 + 2, 8, 1.155 + 4, 6, 1.156 + -0, -1, 1.157 + -2, -3, 1.158 + 10, 12, 1.159 + -4, -5, 1.160 + -6, -7 1.161 +}; 1.162 + 1.163 +void vp8_init_mbmode_probs(VP8_COMMON *x) 1.164 +{ 1.165 + vpx_memcpy(x->fc.ymode_prob, vp8_ymode_prob, sizeof(vp8_ymode_prob)); 1.166 + vpx_memcpy(x->fc.uv_mode_prob, vp8_uv_mode_prob, sizeof(vp8_uv_mode_prob)); 1.167 + vpx_memcpy(x->fc.sub_mv_ref_prob, sub_mv_ref_prob, sizeof(sub_mv_ref_prob)); 1.168 +} 1.169 + 1.170 +void vp8_default_bmode_probs(vp8_prob p [VP8_BINTRAMODES-1]) 1.171 +{ 1.172 + vpx_memcpy(p, vp8_bmode_prob, sizeof(vp8_bmode_prob)); 1.173 +} 1.174 +