1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libvpx/vp8/common/entropy.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,189 @@ 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 +#include "entropy.h" 1.15 +#include "blockd.h" 1.16 +#include "onyxc_int.h" 1.17 +#include "vpx_mem/vpx_mem.h" 1.18 + 1.19 +#include "coefupdateprobs.h" 1.20 + 1.21 +DECLARE_ALIGNED(16, const unsigned char, vp8_norm[256]) = 1.22 +{ 1.23 + 0, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 1.24 + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1.25 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.26 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.27 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.28 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.29 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.30 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.31 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.32 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.33 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.34 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.35 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.36 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.37 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.38 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 1.39 +}; 1.40 + 1.41 +DECLARE_ALIGNED(16, const unsigned char, vp8_coef_bands[16]) = 1.42 +{ 0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7}; 1.43 + 1.44 +DECLARE_ALIGNED(16, const unsigned char, 1.45 + vp8_prev_token_class[MAX_ENTROPY_TOKENS]) = 1.46 +{ 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0}; 1.47 + 1.48 +DECLARE_ALIGNED(16, const int, vp8_default_zig_zag1d[16]) = 1.49 +{ 1.50 + 0, 1, 4, 8, 1.51 + 5, 2, 3, 6, 1.52 + 9, 12, 13, 10, 1.53 + 7, 11, 14, 15, 1.54 +}; 1.55 + 1.56 +DECLARE_ALIGNED(16, const short, vp8_default_inv_zig_zag[16]) = 1.57 +{ 1.58 + 1, 2, 6, 7, 1.59 + 3, 5, 8, 13, 1.60 + 4, 9, 12, 14, 1.61 + 10, 11, 15, 16 1.62 +}; 1.63 + 1.64 +/* vp8_default_zig_zag_mask generated with: 1.65 + 1.66 + void vp8_init_scan_order_mask() 1.67 + { 1.68 + int i; 1.69 + 1.70 + for (i = 0; i < 16; i++) 1.71 + { 1.72 + vp8_default_zig_zag_mask[vp8_default_zig_zag1d[i]] = 1 << i; 1.73 + } 1.74 + 1.75 + } 1.76 +*/ 1.77 +DECLARE_ALIGNED(16, const short, vp8_default_zig_zag_mask[16]) = 1.78 +{ 1.79 + 1, 2, 32, 64, 1.80 + 4, 16, 128, 4096, 1.81 + 8, 256, 2048, 8192, 1.82 + 512, 1024, 16384, -32768 1.83 +}; 1.84 + 1.85 +const int vp8_mb_feature_data_bits[MB_LVL_MAX] = {7, 6}; 1.86 + 1.87 +/* Array indices are identical to previously-existing CONTEXT_NODE indices */ 1.88 + 1.89 +const vp8_tree_index vp8_coef_tree[ 22] = /* corresponding _CONTEXT_NODEs */ 1.90 +{ 1.91 + -DCT_EOB_TOKEN, 2, /* 0 = EOB */ 1.92 + -ZERO_TOKEN, 4, /* 1 = ZERO */ 1.93 + -ONE_TOKEN, 6, /* 2 = ONE */ 1.94 + 8, 12, /* 3 = LOW_VAL */ 1.95 + -TWO_TOKEN, 10, /* 4 = TWO */ 1.96 + -THREE_TOKEN, -FOUR_TOKEN, /* 5 = THREE */ 1.97 + 14, 16, /* 6 = HIGH_LOW */ 1.98 + -DCT_VAL_CATEGORY1, -DCT_VAL_CATEGORY2, /* 7 = CAT_ONE */ 1.99 + 18, 20, /* 8 = CAT_THREEFOUR */ 1.100 + -DCT_VAL_CATEGORY3, -DCT_VAL_CATEGORY4, /* 9 = CAT_THREE */ 1.101 + -DCT_VAL_CATEGORY5, -DCT_VAL_CATEGORY6 /* 10 = CAT_FIVE */ 1.102 +}; 1.103 + 1.104 +/* vp8_coef_encodings generated with: 1.105 + vp8_tokens_from_tree(vp8_coef_encodings, vp8_coef_tree); 1.106 +*/ 1.107 +vp8_token vp8_coef_encodings[MAX_ENTROPY_TOKENS] = 1.108 +{ 1.109 + {2, 2}, 1.110 + {6, 3}, 1.111 + {28, 5}, 1.112 + {58, 6}, 1.113 + {59, 6}, 1.114 + {60, 6}, 1.115 + {61, 6}, 1.116 + {124, 7}, 1.117 + {125, 7}, 1.118 + {126, 7}, 1.119 + {127, 7}, 1.120 + {0, 1} 1.121 +}; 1.122 + 1.123 +/* Trees for extra bits. Probabilities are constant and 1.124 + do not depend on previously encoded bits */ 1.125 + 1.126 +static const vp8_prob Pcat1[] = { 159}; 1.127 +static const vp8_prob Pcat2[] = { 165, 145}; 1.128 +static const vp8_prob Pcat3[] = { 173, 148, 140}; 1.129 +static const vp8_prob Pcat4[] = { 176, 155, 140, 135}; 1.130 +static const vp8_prob Pcat5[] = { 180, 157, 141, 134, 130}; 1.131 +static const vp8_prob Pcat6[] = 1.132 +{ 254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129}; 1.133 + 1.134 + 1.135 +/* tree index tables generated with: 1.136 + 1.137 + void init_bit_tree(vp8_tree_index *p, int n) 1.138 + { 1.139 + int i = 0; 1.140 + 1.141 + while (++i < n) 1.142 + { 1.143 + p[0] = p[1] = i << 1; 1.144 + p += 2; 1.145 + } 1.146 + 1.147 + p[0] = p[1] = 0; 1.148 + } 1.149 + 1.150 + void init_bit_trees() 1.151 + { 1.152 + init_bit_tree(cat1, 1); 1.153 + init_bit_tree(cat2, 2); 1.154 + init_bit_tree(cat3, 3); 1.155 + init_bit_tree(cat4, 4); 1.156 + init_bit_tree(cat5, 5); 1.157 + init_bit_tree(cat6, 11); 1.158 + } 1.159 +*/ 1.160 + 1.161 +static const vp8_tree_index cat1[2] = { 0, 0 }; 1.162 +static const vp8_tree_index cat2[4] = { 2, 2, 0, 0 }; 1.163 +static const vp8_tree_index cat3[6] = { 2, 2, 4, 4, 0, 0 }; 1.164 +static const vp8_tree_index cat4[8] = { 2, 2, 4, 4, 6, 6, 0, 0 }; 1.165 +static const vp8_tree_index cat5[10] = { 2, 2, 4, 4, 6, 6, 8, 8, 0, 0 }; 1.166 +static const vp8_tree_index cat6[22] = { 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 1.167 + 14, 14, 16, 16, 18, 18, 20, 20, 0, 0 }; 1.168 + 1.169 +const vp8_extra_bit_struct vp8_extra_bits[12] = 1.170 +{ 1.171 + { 0, 0, 0, 0}, 1.172 + { 0, 0, 0, 1}, 1.173 + { 0, 0, 0, 2}, 1.174 + { 0, 0, 0, 3}, 1.175 + { 0, 0, 0, 4}, 1.176 + { cat1, Pcat1, 1, 5}, 1.177 + { cat2, Pcat2, 2, 7}, 1.178 + { cat3, Pcat3, 3, 11}, 1.179 + { cat4, Pcat4, 4, 19}, 1.180 + { cat5, Pcat5, 5, 35}, 1.181 + { cat6, Pcat6, 11, 67}, 1.182 + { 0, 0, 0, 0} 1.183 +}; 1.184 + 1.185 +#include "default_coef_probs.h" 1.186 + 1.187 +void vp8_default_coef_probs(VP8_COMMON *pc) 1.188 +{ 1.189 + vpx_memcpy(pc->fc.coef_probs, default_coef_probs, 1.190 + sizeof(default_coef_probs)); 1.191 +} 1.192 +